Vite @ alias path All In One
error
@
alias path
solution
// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
const path = require('path')
// https://vitejs.dev/config/
export default defineConfig({
resolve:{
alias:{
'@' : path.resolve(__dirname, './src')
},
},
plugins: [vue()]
})
https://vueschool.io/articles/vuejs-tutorials/import-aliases-in-vite/
https://stackoverflow.com/questions/66043612/vue3-vite-project-alias-src-to-not-working
https://vitejs.dev/config/#resolve-alias
demo
<template>
<!-- <>react fragment</> -->
<!-- <template>vue fragment</template> -->
<template v-if="true">
<div>{{store.msg}}</div>
</template>
<template v-if="true">
<div>{{store.getMsg}}</div>
<!-- <pre>{{jsonString}}</pre> -->
<pre>❓ {{store.msg}}</pre>
<span v-pre>{{ this will not be compiled }}❓ {{store.msg}}</span>
<button @click="updateMsg">Pinia
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。