非常感谢 番薯有才 在飞书中的回复,以下核心步骤均由他提供:
- 使用
vite
创建一个vue-ts
类型的项目,并安装所需的最小依赖:
yarn create vite arco-design-vue-auto-import-tests --template vue-ts
cd arco-design-vue-auto-import-tests
yarn
yarn add @arco-design/web-vue
yarn add less less-loader unplugin-vue-components @arco-plugins/vite-vue -D
vite.config.ts
添加以下代码,实现模板和 import 自动导入:
import { vitePluginForArco } from "@arco-plugins/vite-vue";
import Components from 'unplugin-vue-components/vite';
import { ArcoResolver } from 'unplugin-vue-components/resolvers';
export default defineConfig({
plugins: [
...
Components({
resolvers: [ArcoResolver({ resolveIcons: true, sideEffect: false })],
dts: false,
}),
vitePluginForArco({
theme: '填写主题包名,没有就不用配置这个属性',
varsInjectScope: ['*'],
}),
],
...
});
src/vite-env.d.ts
添加以下代码,实现模板组件提示:
declare global {
import '@arco-design/web-vue/es/components';
}
标签:vue,ts,design,import,arco,vite
From: https://www.cnblogs.com/myesn/p/16644401.html