mpvue 使用第三方ui庫(kù)

使用第三方ui組件的問(wèn)題

以vant-weapp 為例子

直接通過(guò) git 下載 Vant Weapp 源代碼

git clone https://github.com/youzan/vant-weapp.git

下載完了之后將dist 目錄給復(fù)制出來(lái),

進(jìn)入你的mpvue項(xiàng)目目錄,執(zhí)行npm run dev 或者 npm run build, 之后目錄下會(huì)多出一個(gè)dist文件夾,將剛剛下載的vant-weapp目錄中的dist目錄改下名字改成你自己喜歡的名字。比如我直接改成vant-weapp,然后將vant-weapp文件夾復(fù)制到mpvue項(xiàng)目目錄下的 dist 目錄里面。

然后比如我們的index頁(yè)面中想使用vant-wapp 中的某個(gè)組件:

我們找到我們定義的頁(yè)面 /pages/index/main.json文件

添加

"usingComponents": {
    "van-button": "./../../vant-weapp/button/index",
    "van-dialog": "./../../vant-weapp/dialog/index",
    "van-notice-bar": "./../../vant-weapp/notice-bar/index",
    "van-action-sheet": "./../../vant-weapp/action-sheet/index",
    "van-search": "./../../vant-weapp/search/index"
  }

{
  "backgroundTextStyle": "dark",
  "navigationBarTitleText": "頁(yè)面標(biāo)題",
  "usingComponents": {
    "van-button": "./../../vant-weapp/button/index",
    "van-dialog": "./../../vant-weapp/dialog/index",
    "van-notice-bar": "./../../vant-weapp/notice-bar/index",
    "van-action-sheet": "./../../vant-weapp/action-sheet/index",
    "van-search": "./../../vant-weapp/search/index"
  }
}

需要注意的是 ./../../vant-weapp/button/index 這個(gè)路徑是mpvue項(xiàng)目下的dist中的相對(duì)路徑。

如有不明白的地方可聯(lián)系 qq:836717428

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容