0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ファイルパスの書き方(カレントディレクトリとルートディレクトリ)

Posted at

相対パスを指定する時、"./"の意味を勘違いしていたのでメモ。

結論:"./"の意味は、カレントディレクトリの中という意味。

例えば以下のようなディレクトリ構成の場合
※publicフォルダがルートディレクトリ
ディレクトリ構造.png

<view/players/index.htmlでpublic/js/script.jsを呼び出したい場合>
正解:/js/script.js
★先頭が"/"の場合、ルートディレクトリを示す。

私の間違え:./js/script.js
先頭が"./"の場合、カレントディレクトを表しているが、
意味合いとしては"カレントディレクトの中"という意味になる。
→絶対パスで表すと、view/players/js/script.js になってしまう。

参考サイト:
https://www.tohoho-web.com/ex/draft/path.htm

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?