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(“成功了”)
原创文章,作者:sunnyman218,如若转载,请注明出处:https://blog.ytso.com/267984.html