安装
npm install vant --save
// 或者
yarn add vant
引入
// 全局按需引入,在main.js中
import Vue from 'vue';
import 'vant/lib/index.css';
import { Toast, Picker, Button,} from 'vant';
Vue.use(Toast);
Vue.use(Picker);
Vue.use(Button);
//局部注册
components: {
[Dialog.Component.name]: Dialog.Component
}
注意:
框架内有组件和函数两种形式的。
函数形式的调用全局引入的话,是挂在到Vue 的 prototype 上挂载 dialog等方法,直接使用this.dialog 等方法,直接使用this.dialog等方法,直接使用this.dialog.alert({message: " 我是提示框哦~"})
本文介绍如何通过npm或yarn安装Vant UI框架,并在Vue项目中全局或局部引入其组件。提供了具体代码示例,包括如何注册组件及使用Toast、Picker和Button等组件。
1273

被折叠的 条评论
为什么被折叠?



