微信小程序使用Vant Weapp组件库
微信小程序使用Vant Weapp组件库
一、打开微信小程序开发工具,右击miniprogram,选择再终端中打开。
二、引入Vant组件库
1、首先运行 npm init
就会生成 package.json
2、运行npm i vant-weapp -S --production
3.安装成功后 点击 工具 => 构建npm
成功后显示下图
三、使用组件库
首先在json文件中引入组件
“van-button”: “vant-weapp/button/index”
“van-search”:“vant-weapp/search/index”
然后去官网找到想用的样式,直接用在wxml中,官网链接vant官网
注意:对于vant库来说其实你并不需要在页面对应的js中require vant-weapp组件。