美文网首页vue3
vue3 解决@问题

vue3 解决@问题

作者: 鹿简luz | 来源:发表于2022-06-23 15:48 被阅读0次

vite.config.js文件内

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
const path = require('path');//解决@路径问题

export default defineConfig({
  plugins: [vue()],
    resolve: {
        // 配置路径别名
        alias:{
            '@': path.resolve(__dirname,'./src')
        }
    }
})

页面中使用:

.box{
        width:200px;
        height:200px;
        background:url('@/assets/logo.png') no-repeat;
        background-size: cover;
    }

相关文章

网友评论

    本文标题:vue3 解决@问题

    本文链接:https://www.haomeiwen.com/subject/mkcmvrtx.html