Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

vue.config.js中配置了alias,在css里background: url("~@/xxx"),引用的图片并没有生效

问题

vue.config.js中配置了alias,在css里background: url(),路径正确,引用的图片并没有生效

描述

//"vue": "^2.6.11"
//vue.config.js
    resolve: {
      alias: {
        "~@": path.resolve(__dirname, 'src/')
      }
    }

image.png
image.png


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

1 Reply

0 votes
by (71.8m points)

描述一下排查过程

首先,不做额外的配置也是可以的
其次,styles里面已经看得出图片已经转换为base64了,说明转换没毛病
再次,background属性前有个警告图标并且对应属性被划掉了,说明属性名有误或者属性值格式有误
最后,已经说的这么直白,自己应该能找出问题出在哪儿了吧


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...