Vant Weapp 是有贊移動(dòng)端組件庫 Vant 的小程序版本,兩者基于相同的視覺規(guī)范,提供一致的 API 接口,助力開發(fā)者快速搭建小程序應(yīng)用
兩大參考神獸:
文檔:https://youzan.github.io/vant-weapp/#/intro
開源:https://github.com/youzan/vant-weapp
1:桌面新建一個(gè)vant文件夾

2:打開微信開發(fā)者工具,在這個(gè)文件里新建項(xiàng)目

3:從github上面下載源碼文件:開源:https://github.com/youzan/vant-weapp

?
4:打開文件,復(fù)制dist文件

5:將dist文件黏貼在項(xiàng)目目錄里面

6:打開Vant Weapp的使用文檔:文檔:https://youzan.github.io/vant-weapp/#/button
現(xiàn)在來在index界面來使用一個(gè)按鈕的樣式:
7:在 json 文件中配置button組件,修改路徑
{ "usingComponents": { "van-button": "../../dist/button/index" } }

8:wxml界面寫一點(diǎn)文檔里面的代碼
<van-button type="default">默認(rèn)按鈕</van-button> <van-button type="primary">主要按鈕</van-button> <van-button type="warning">警告按鈕</van-button> <van-button type="danger">危險(xiǎn)按鈕</van-button>
9:引入成功:然后你就可以依靠文檔來進(jìn)行復(fù)制黏貼了,因?yàn)樽约簩慶ss的日子真的又煩人又浪費(fèi)時(shí)間吶。

最后,為啥推薦這個(gè)組件庫,因?yàn)閷?shí)在是省力氣,拿這個(gè)步驟條時(shí)間戳來說,前兩天寫了好一會(huì)

現(xiàn)在只需要三步即可完成,30秒中不到全部搞定,當(dāng)然了,不推薦新手使用這個(gè)復(fù)制黏貼的方法,畢竟代碼功夫還是需要一筆一畫來提升境界的。
wxml
<view> <van-steps steps="{{ steps }}" active="{{ active }}" /> </view>
json:
{ "usingComponents": { "van-steps": "../../dist/steps/index" } }
js
Page({ data: { steps: [ { text: '步驟一', desc: '描述信息' }, { text: '步驟二', desc: '描述信息' }, { text: '步驟三', desc: '描述信息' }, { text: '步驟四', desc: '描述信息' } ] } });
ok,完成,沒錯(cuò),真的就是這么簡(jiǎn)單。
原文作者:祈澈姑娘?
90后前端妹子,愛編程,愛運(yùn)營(yíng),愛折騰。
堅(jiān)持總結(jié)工作中遇到的技術(shù)問題,堅(jiān)持記錄工作中所所思所見
本文摘自 :https://blog.51cto.com/u