web front-end to file a reference to rules

web front commonly used file .html .css .js. But when introduced resources (such as images) using css files and html, the path may not be the same. The following summarizes a few.

Using a relative path introduced rules:

  1. html or js introduced pictures, html to count by category
  2. css introduction of picture, calculated according to the css directory.

What is html directory:

For example: HTTP: // ip / a / b request to come back are html files, html files directory is / a / folder, if this piece of code html:

<link rel="stylesheet" href="css/aa.css">

Well, actually referenced css file path is /a/css/aa.css

What is the css directory

It simply is css file to store addresses. Here is /a/css
connected to the above address, css file ( /a/css/aa.css) after being referenced, it has a code background:url('img/cc.png').
Then cc.pngthe address is actually referenced /a/css/img/cc.png.

Problems:

If the front end of the route and the use historymode is introduced using relative path, the problem may be. When the route reaches the level 2 address directory for example: http://ip/1/2this page if there is a reference to a relative path, it will fail. All relative references will be address before adding /1/the directory address. When you refresh this page, bug came out.


ps: here mentioned address before the address is not packed, it is real after packed address. The next one will note this point, using a nginx + port, a plurality of single-page application deployment using distal route (History Mode).

Guess you like

Origin www.cnblogs.com/qianduanwriter/p/11817972.html