vite import插件

# 安装组件
pnpm install -D unplugin-vue-components unplugin-auto-import

# 修改配置文件
// vite.config.ts
import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export default defineConfig({
  // ...
  plugins: [
    // ...
    AutoImport({
      resolvers: [ElementPlusResolver()],
      imports:['vue','vue-router']
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
})

# 不用导入也可以使用ref
import { ref } from 'vue'
posted @ 2023-04-03 01:11  LeoShi2020  阅读(56)  评论(0编辑  收藏  举报