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"])

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM