ColorUI是一個Css類的UI組件庫!不是一個Js框架。相比於同類小程序組件庫,ColorUI更注重於視覺交互!html
瀏覽GitHub:https://github.com/weilanwl/ColorUIgit
→ Githubgithub
將 /demo/ 下的 colorui.wxss 和 icon.wxss 複製到小程序的根目錄下小程序
在 app.wxss 引入兩個文件bash
@import "icon.wxss"; @import "colorui.wxss"; 複製代碼
複製 /template/ 文件夾並重命名爲你的項目,微信開發者工具導入爲小程序就能夠使用ColorUI了微信
App.js
獲取系統參數並寫入全局參數。markdown
//App.js App({ onLaunch: function() { wx.getSystemInfo({ success: e => { this.globalData.StatusBar = e.statusBarHeight; let custom = wx.getMenuButtonBoundingClientRect(); this.globalData.Custom = custom; this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight; } }) } }) 複製代碼
Page.js 頁面配置獲取全局參數。微信開發
//Page.js
const app = getApp()
Page({
data: {
StatusBar: app.globalData.StatusBar,
CustomBar: app.globalData.CustomBar,
Custom: app.globalData.Custom
}
})
複製代碼
Page.wxml 頁面構造導航。更多導航樣式請下載Demo查閱 操做條組件。app
<view class="cu-custom" style="height:{{CustomBar}}px;"> <view class="cu-bar fixed bg-gradual-pink" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}px;"> <navigator class='action border-custom' open-type="navigateBack" delta="1" hover-class="none" style='width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)'> <text class='icon-back'></text> <text class='icon-homefill'></text> </navigator> <view class='content' style='top:{{StatusBar}}px;'>操做條</view> </view> </view> 複製代碼
按照官方 自定義 tabBar 配置好Tabbar (開發工具和版本庫請使用最新版)。框架
使用ColorUI配置Tabbar只須要更改 Wxml 頁的內容便可。 更多Tabbar樣式請下載Demo查閱 操做條組件。
/custom-tab-bar/index.wxml
<view class="cu-bar tabbar bg-white shadow"> <view class="action" wx:for="{{list}}" wx:key="index" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab"> <view class='icon-cu-image'> <image src='{{selected === index ? item.selectedIconPath : item.iconPath}}' class='{{selected === index ? "animation" : "animation"}}'></image> </view> <view class='{{selected === index ? "text-green" : "text-gray"}}'>{{item.text}}</view> </view> </view> 複製代碼
ColorUI是一個高度自定義的Css樣式庫,包含了開發經常使用的元素和組件,元素組件之間也能相互嵌套使用。我也會不按期更新一些擴展到源碼。
感謝閱讀。