uni-app中引入vant weapp方法

很多人在使用uni-app時(shí)會(huì)用到vant weapp,這樣就不用我們自己再去做很多樣式上邊的工作

1、我們到https://github.com/youzan/vant-weapp下載最新的壓縮包
2、在自己項(xiàng)目的根目錄創(chuàng)建wxcomponents>vant,然后將壓縮包內(nèi)的dist文件夾直接拷入vant文件中,格式如下圖(不是必須這樣做,只是為了文件目錄結(jié)構(gòu)清晰)

image.png

3、在根目錄下App.vue中引入index.wxss,如下圖

@import "/wxcomponents/vant/dist/common/index.wxss";

image.png

4、在pages.json頁面將vant的組件注冊到對應(yīng)的頁面,參考https://youzan.github.io/vant-weapp/#/intro頁面的組件配置方法
如下圖

"usingComponents": {
    "van-row": "/wxcomponents/vant/dist/row/index",
    "van-col": "/wxcomponents/vant/dist/col/index",
    "van-icon": "/wxcomponents/vant/dist/icon/index",
    "van-button": "/wxcomponents/vant/dist/button/index"
}
image.png

5、現(xiàn)在,即可在配置好的頁面使用當(dāng)前組件

<van-button
  icon="bulb-o"
  color="linear-gradient(to bottom, rgb(255, 96, 52), rgb(238, 10, 36), rgb(255, 96, 52))"
/>
image.png

6、也可以將usingComponents配置到globalStyle下,這樣全局頁面都可以使用


image.png

如果有什么不清楚可留言

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

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