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样式库,包含了开发经常使用的元素和组件,元素组件之间也能相互嵌套使用。我也会不按期更新一些扩展到源码。
感谢阅读。