vue3 vite @ assets backgroud设置
vite.config.js
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import createVitePlugins from './vite/plugins'
const alias = { // 设置路径 '~': path.resolve(__dirname, './'), // 设置别名 '@': path.resolve(__dirname, './src') } if (command === 'serve') { // 解决警告You are running the esm-bundler build of vue-i18n. alias['vue-i18n'] = 'vue-i18n/dist/vue-i18n.cjs.js'; }
jsconfig.json
/* 主要作用是vscode导入使用别名时可以自动化提示文件路径 */ { "compilerOptions": { "experimentalDecorators": true, "baseUrl": "./", "paths": { "@/*": ["src/*"] } }, "exclude": ["node_modules", "dist", ".vscode"] }
使用
.bg { background: url(@assets/images/kanbanbg.png) }
 
                    
                     
                    
                 
                    
                
 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号