vant官网网址:Vant 4 - Lightweight Mobile UI Components built on Vue
第一步安装vant
# 通过 npm 安装 npm i @vant/weapp -S --production
# 通过 yarn 安装 yarn add @vant/weapp --production
# 安装 0.x 版本 npm i vant-weapp -S --production
新建目录文件夹,命名为wxcomponents,打开
node_modules/@vant/weapp
将weapp
里的dist
文件复制到 wxcomponents文件里面
打开 App.vue引入
@import "/wxcomponents/dist/common/index.wxss";
打开 pages.json文件,复制下面这句话
"usingComponents": {
"van-button": "wxcomponents/dist/button/index"
}
可以在 globalStyle里面全局注册,也可以在用到的pages路由下注册