less 中使用 url 设置问题


.content {
  background-image: url("@/assets/imgs/logo.png");
}

报错

 ERROR  Failed to compile with 1 error                                             09:49:35

This relative module was not found:

* ./@/assets/imgs/logo.png in ./node_modules/css-loader/dist/cjs.js??ref--10-oneOf-1-1!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/stylePostLoader.js!./node_modules/postcss-loader/src??ref--10-oneOf-1-2!./node_modules/less-loader/dist/cjs.js??ref--10-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./src/views/Login.vue?vue&type=style&index=0&id=26084dc2&lang=less&scoped=true

解决

.content(@url) {
  background-image: ~'url("@/assets/imgs/logo.png")';
}

注意 (@url) | ~'url()'


文章作者: April-cl
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 April-cl !
  目录