Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@ for handling assets in vue js not working

i want to set address of my photos from src folder and based on vue doc i have to use @ . the problem is when i use it jetbrains underline the address with red line and also my page not compile anymore the error is:

Failed to compile.

./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-7ba5bd90","scoped":false,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"indentedSyntax":true,"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue Module not found: Error: Can't resolve './@/assets/image/background.png' in '/home/sina/WebstormProjects/landing-vue/src' @ ./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-7ba5bd90","scoped":false,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"indentedSyntax":true,"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 7:749-791 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-7ba5bd90","scoped":false,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"indentedSyntax":true,"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue @ ./src/App.vue @ ./src/main.js @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

and also this is the css:

background: url("@/assets/image/background.png");
like image 410
sepehr Avatar asked Dec 02 '22 11:12

sepehr


1 Answers

try this: background: url("~@/assets/image/background.png")

like image 124
Kimo Zhang Avatar answered Dec 26 '22 02:12

Kimo Zhang