vue3 vite 引进vant
作者:互联网
1、安装
# 通过 npm 安装 npm i unplugin-vue-components -D
2、配置插件vite.config.js
import vue from '@vitejs/plugin-vue'; import Components from 'unplugin-vue-components/vite'; import { VantResolver } from 'unplugin-vue-components/resolvers'; export default { plugins: [ vue(), Components({ resolvers: [VantResolver()], }), ], };
3、引入样式main.js
如不引入此样式, 像Toast这类组件显示会异常出不来
import "vant/lib/index.css"
4、使用
import { Toast } from "vant";
Toast("成功了")
标签:Toast,vue,vant,unplugin,vue3,import,vite 来源: https://www.cnblogs.com/Nyan-Workflow-FC/p/16380677.html