Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

vue-cli4 背景图片的路径问题

比如我想把项目部署到/vue目录下

vue.config.js里的publicPath是/vue/,assertDir是static

我的一个样式里是这样写的

background-image: url(/vue/static/img/sprite.1.2.4.png)

这样是绝对路径没问题,那如果我想换根目录部署,这个样式里的/vue前缀该怎么动态的改变?(用的是sass)

忘了说了,static是在public下,public和src同级


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

正常你文件里引入图片就直接按 相对路径引用, 通过webpack打包后他会自动给你补上 vue/static


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...