uni-app項目中引入Vant?UI組件庫完美避坑指南(純凈版)
第一步,HBuilder X中新建一個uni-app的項目
1、添加項目名稱,選擇文件路徑
2、選擇默認模板
3、Vue版本選擇(若無其他需求,點擊創(chuàng)建即可)
第二步,HBuilder X提示項目創(chuàng)建成功,在HBuilder X用命令行窗口打開創(chuàng)建的項目(或直接在創(chuàng)建的項目文件夾內(nèi)用cmd指令打開)
第三步,輸入npm init -y 指令,創(chuàng)建項目配置文件(即package.json);
第四步,輸入npm i @vant/weapp -S --production下載vant
安裝完成后,項目中會多出一個依賴項,也代表安裝成功
第五步,在項目的根路徑下,創(chuàng)建wxcomponents目錄,并將依賴項(node_modules)中@vant文件夾下的dist復(fù)制到wxcomponents,并修改文件夾名為vant;
第六步,在pages.json中注冊并引入組件
以下為組件的全局注冊,可根據(jù)需求按需導(dǎo)入組件:
"usingComponents": { "van-action-sheet": "/wxcomponents/vant/action-sheet/index", "van-area": "/wxcomponents/vant/area/index", "van-button": "/wxcomponents/vant/button/index", "van-card": "/wxcomponents/vant/card/index", "van-cell": "/wxcomponents/vant/cell/index", "van-cell-group": "/wxcomponents/vant/cell-group/index", "van-checkbox": "/wxcomponents/vant/checkbox/index", "van-checkbox-group": "/wxcomponents/vant/checkbox-group/index", "van-col": "/wxcomponents/vant/col/index", "van-dialog": "/wxcomponents/vant/dialog/index", "van-field": "/wxcomponents/vant/field/index", "van-goods-action": "/wxcomponents/vant/goods-action/index", "van-goods-action-icon": "/wxcomponents/vant/goods-action-icon/index", "van-goods-action-button": "/wxcomponents/vant/goods-action-button/index", "van-icon": "/wxcomponents/vant/icon/index", "van-loading": "/wxcomponents/vant/loading/index", "van-nav-bar": "/wxcomponents/vant/nav-bar/index", "van-notice-bar": "/wxcomponents/vant/notice-bar/index", "van-notify": "/wxcomponents/vant/notify/index", "van-panel": "/wxcomponents/vant/panel/index", "van-popup": "/wxcomponents/vant/popup/index", "van-progress": "/wxcomponents/vant/progress/index", "van-radio": "/wxcomponents/vant/radio/index", "van-radio-group": "/wxcomponents/vant/radio-group/index", "van-row": "/wxcomponents/vant/row/index", "van-search": "/wxcomponents/vant/search/index", "van-slider": "/wxcomponents/vant/slider/index", "van-stepper": "/wxcomponents/vant/stepper/index", "van-steps": "/wxcomponents/vant/steps/index", "van-submit-bar": "/wxcomponents/vant/submit-bar/index", "van-swipe-cell": "/wxcomponents/vant/swipe-cell/index", "van-switch": "/wxcomponents/vant/switch/index", "van-tab": "/wxcomponents/vant/tab/index", "van-tabs": "/wxcomponents/vant/tabs/index", "van-tabbar": "/wxcomponents/vant/tabbar/index", "van-tabbar-item": "/wxcomponents/vant/tabbar-item/index", "van-tag": "/wxcomponents/vant/tag/index", "van-toast": "/wxcomponents/vant/toast/index", "van-transition": "/wxcomponents/vant/transition/index", "van-tree-select": "/wxcomponents/vant/tree-select/index", "van-datetime-picker": "/wxcomponents/vant/datetime-picker/index", "van-rate": "/wxcomponents/vant/rate/index", "van-collapse": "/wxcomponents/vant/collapse/index", "van-collapse-item": "/wxcomponents/vant/collapse-item/index", "van-picker": "/wxcomponents/vant/picker/index" }
如此,即完成了Vant組件庫的引入!
總結(jié)
到此這篇關(guān)于uni-app項目中引入Vant UI組件庫的文章就介紹到這了,更多相關(guān)uni-app引入Vant UI組件庫內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
el-table-column 內(nèi)容不自動換行的解決方法
本文主要介紹了el-table-column 內(nèi)容不自動換行的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08VUE跳轉(zhuǎn)外部鏈接與網(wǎng)頁的方法示例
這篇文章主要給大家介紹了關(guān)于VUE跳轉(zhuǎn)外部鏈接與網(wǎng)頁的方法,記錄一下在vue項目中如何實現(xiàn)跳轉(zhuǎn)到一個新頁面,需要的朋友可以參考下2023-06-06Vue3+El-Plus實現(xiàn)表格行拖拽功能完整代碼
在vue3+elementPlus網(wǎng)站開發(fā)中,詳細完成el-table表格的鼠標拖拽/拖曳/拖動排序,下面這篇文章主要給大家介紹了關(guān)于Vue3+El-Plus實現(xiàn)表格行拖拽功能的相關(guān)資料,需要的朋友可以參考下2024-05-05antfu大佬的v-lazy-show教我學(xué)會了怎么編譯模板指令
這篇文章主要介紹了antfu大佬的v-lazy-show,我學(xué)會了怎么編譯模板指令示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-04-04詳解Vue CLI3配置之filenameHashing使用和源碼設(shè)計使用和源碼設(shè)計
這篇文章主要介紹了詳解Vue CLI3配置之filenameHashing使用和源碼設(shè)計使用和源碼設(shè)計,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-08-08Vue項目打包、合并及壓縮優(yōu)化網(wǎng)頁響應(yīng)速度
網(wǎng)站頁面的響應(yīng)速度與用戶體驗息息相關(guān),直接影響到用戶是否愿意繼續(xù)訪問你的網(wǎng)站,所以這篇文章主要給大家介紹了關(guān)于Vue項目打包、合并及壓縮優(yōu)化網(wǎng)頁響應(yīng)速度的相關(guān)資料,需要的朋友可以參考下2021-07-07Vue高性能列表GridList組件及實現(xiàn)思路詳解
這篇文章主要為大家介紹了Vue高性能列表GridList組件及實現(xiàn)思路詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-11-11