Background image path to solve the wrong problem after vue project package

After packing on the line vue project today, I found that the background image does not load up, other images load properly, that is not loaded out of the background image is introduced in the css file, find the picture of debugging wrong path, change the build folder utils. js file, then the background image can be properly loaded.
Open build / utils.js, add a line of code:

publicPath: '../../',

Here Insert Picture Description
Background images in a production environment path wrong reasons:
the project after the build, you need to read a static resource, static resources are divided into three, JS, CSS, IMG,
is displayed by the normal img tags that bring a picture, because as img html tags, his path is index.html began a visit, he walked static / img / 'Image name' is able to access the correct picture; introduced in css file picture, in the css directory and no static directory . So in this case we need to roll back to the root of the two before they can get to the correct picture.

Published 17 original articles · won praise 1 · views 2190

Guess you like

Origin blog.csdn.net/qq_41512822/article/details/104044140