其他分享
首页 > 其他分享> > Vite @ alias path All In One

Vite @ alias path All In One

作者:互联网

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 

标签:jsonString,const,log,alias,json,Vite,path,import,store
来源: https://www.cnblogs.com/xgqfrms/p/16172489.html