Java教程

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 

	
这篇关于Vite @ alias path All In One的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!