1.安装vant
npm install vant
2.引入vant
import { createSSRApp } from 'vue'; import Vant from 'vant'; import 'vant/lib/index.css'; import App from './App.vue'; const app = createSSRApp(App); app.use(Vant); export default app;
3.在pages.json中配置自动引入
"easycom": { "^van-(.*)": "vant/es/#/$1" }
4.引入使用
<van-button type="primary">主要按钮</van-button>
5.特殊组件,在main.js中增加
import { Toast, Dialog } from 'vant'; app.config.globalProperties.$toast = Toast; app.config.globalProperties.$dialog = Dialog;
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com