mpvue中使用vant-weapp

安装

# 通过 npm 安装
npm i vant-weapp -S --production
# 通过 yarn 安装
yarn add vant-weapp --production
# 直接通过 git 下载 Vant Weapp 源代码,并将dist或lib目录拷贝到自己的项目中
git clone https://github.com/youzan/vant-weapp.git

引入

 

// 以下方法使用于git下载安装的方法

// 全局引入 app.json
"window": {
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "WeChat",
    "navigationBarTextStyle": "black"
},
"usingComponents": {
    "van-steps": "/static/vant/steps/index"
}
// 页面引入 main.json
{
    "usingComponents": {
        "van-steps": "/static/vant/steps/index"
    },
}    

 

注意  引入组件后,我们需要重新将项目打包一下(npm run build)

    微信小程序开发工具中的打开es6转es5(不然会报错的)

    全局引入"usingComponents"与window同级(报错:无效的 appJSON["window"]["usingComponents"])

 

posted @ 2019-07-30 20:04  绿谷  阅读(4110)  评论(0编辑  收藏  举报