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

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

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

?
?
4:打開文件,復制dist文件
?

?
5:將dist文件黏貼在項目目錄里面
?

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

?
8:wxml界面寫一點文檔里面的代碼
<van-button type="default">默認按鈕</van-button> <van-button type="primary">主要按鈕</van-button> <van-button type="warning">警告按鈕</van-button> <van-button type="danger">危險按鈕</van-button>
9:引入成功:然后你就可以依靠文檔來進行復制黏貼了,因為自己寫css的日子真的又煩人又浪費時間吶。
?

?
最后,為啥推薦這個組件庫,因為實在是省力氣,拿這個步驟條時間戳來說,前兩天寫了好一會
?

?
現(xiàn)在只需要三步即可完成,30秒中不到全部搞定,當然了,不推薦新手使用這個復制黏貼的方法,畢竟代碼功夫還是需要一筆一畫來提升境界的。
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,完成,沒錯,真的就是這么簡單。
原文作者:祈澈姑娘?
90后前端妹子,愛編程,愛運營,愛折騰。
堅持總結工作中遇到的技術問題,堅持記錄工作中所所思所見
本文摘自 :https://blog.51cto.com/u