Front-end path / ./ ../ ../../ ../../../ meaning relative and absolute paths

Transfer: https://blog.csdn.net/cvper/article/details/79955412

First / slash represents the meaning of the root, the root of what is it?

                   Look at the example: F disk there is a folder and a picture vue_bamboos test-me.png

                                    I have a folder under a vue_bamboos, a folder, a document B;

                                    b has a folder index.html file;

                   F---------------------------------------

                            vue_bamboos-------------------

                                        a-------------------------

                                                  b------------------

                                                         index.html---

                             test-me.png---------------------

                    index.html: Shows an image test-me.png, here we use is the root directory, which is our project directory

                                       Level, that is, F disk is our root directory; note that our project directory is vue_bamboos, but

                                      vue_bamboos not the root directory, which is the upper level! ! !

                      

<body>
<img src="/test-me.png" alt="测试根目录">
</body>

The second ./ This represents the current directory, that is, on our index.html and at the same level;

                Suppose we project directory:

                F-----------------------------------

                        vue_bamboos---------------

                                 index.html-------------

                                 test-me.png-----------         

<body>
<img src="./test-me.png" alt="测试根目录">
<img src="test-me.png" alt="测试根目录">
</body>

In other words we can write ./test-me.png or ./ omitted is also possible to directly write test-me.png

This represents the third ../ means to return to the parent directory; 

The fourth ../../ this represents a return to, a back up, the two return;

The fifth ../../../ this more than the above level, it is up to return the three;

。。。。。。。。

../ ../../ ../../../ three is quite easy to understand, because the frequency of use is pricey,

But / and ./ not too common

Relative and absolute paths:

(1) relative path, is in the same site, the location of positioning between different files. File is referenced, obtained relative path in terms of the relative position of the current page based on this relative position.

(2) the absolute path, refers to the complete path.

For a website, external reference files or images are using relative paths, almost no absolute path.

Guess you like

Origin www.cnblogs.com/panghu123/p/11717488.html