天天看點

uniapp使用第三方UI庫(Vant-weapp)流程

最近撸了一個個人小程式項目,前端到後端都是本人所寫,苦逼。。。廢話不多說,直接給大家說一下uniapp使用vant步驟!!!

一、建立目錄

  1. 在項目根目錄中建立wxcomponents目錄(注:與components同路徑)
  2. 在wxcomponents目錄中建立vant目錄
  3. 在vant-weapp的GitHub Releases版塊下載下傳最新的zip包:https://github.com/youzan/vant-weapp/releases
  4. 把下載下傳好的zip包中的dist檔案目錄放到vant目錄下。

    效果:

    uniapp使用第三方UI庫(Vant-weapp)流程

二、使用元件

1.在App.Vue目錄中的style部分引入UI元件庫的樣式檔案:

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

2.在pages.json配置檔案的style中,注冊頁面需要的元件

"globalStyle": {
		"usingComponents":{
					"van-button":"/wxcomponents/vant/dist/button/index"
				}
	}
           

3.在頁面中使用元件

例如:

<van-button type="primary">主要按鈕</van-button>

收工!!!覺得有幫助,順便給部落客一個贊吧————