安裝
# 通過 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"])