基础元素_colorUI文档_基础元素变形图案

高颜值的小程序组件库,值得推荐——ColorUI

介绍

ColorUI是一个高饱和度色彩,注重视觉效果的小程序组件库,可以在国内比较火的uniapp或者原生小程序中进行开发。文章中将进行各组件的截图预览,一定不会让你失望的!




PS:想直接查看组件效果的小伙伴可直接跳到组件预览标题


Github

https://github.com/weilanwl/ColorUI

语雀知识库

https://www.yuque.com/colorui

PS:语雀是一个适合个人和团队的高质量文档知识管理库

在Uniapp中开发

在最新版本的HBuilderX开发工具中已经自带了项目模板,可以通过这个项目模板进行开发,当然也可以单独使用


下面是不通过模板单独引入

下载源码解压获得/Colorui-UniApp文件夹,复制目录下的 /colorui 文件夹到你的项目根目录

App.vue 引入关键Css main.css icon.css

<style>
@import &#;colorui/main.css&#;;
@import &#;colorui/icon.css&#;;
@import &#;app.css&#;; /* 你的项目css */
....
</style>
  • 使用自定义导航栏

导航栏作为常用组件有做简单封装,当然你也可以直接复制代码结构自己修改,达到个性化目的。

App.vue 获得系统信息

onLaunch: function() {
	uni.getSystemInfo({
		success: function(e) {
			// #ifndef MP
			Vue.prototype.StatusBar = e.statusBarHeight;
			if (e.platform == &#;android&#;) {
				Vue.prototype.CustomBar = e.statusBarHeight + ;
			} else {
				Vue.prototype.CustomBar = e.statusBarHeight + ;
			};
			// #endif
			// #ifdef MP-WEIXIN
			Vue.prototype.StatusBar = e.statusBarHeight;
			let custom = wx.getMenuButtonBoundingClientRect();
			Vue.prototype.Custom = custom;
			Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
			// #endif		
			// #ifdef MP-ALIPAY
			Vue.prototype.StatusBar = e.statusBarHeight;
			Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
			// #endif
		}
	})
},
  • pages.json 配置取消系统导航栏
&#;globalStyle&#;: {
	&#;navigationStyle&#;: &#;custom&#;
},

复制代码结构可以直接使用,注意全局变量的获取。

  • 使用封装,在main.js 引入 cu-custom 组件。
import cuCustom from &#;./colorui/components/cu-custom.vue&#;
Vue.component(&#;cu-custom&#;,cuCustom)

page.vue 页面可以直接调用了

<cu-custom bgColor=&#;bg-gradual-blue&#; :isBack=&#;true&#;>
	<block slot=&#;backText&#;>返回</block>
	<block slot=&#;content&#;>导航栏</block>
</cu-custom>

原生使用

下载源码解压获得/demo,复制目录下的 /colorui 文件夹到你的项目根目录

App.wxss 引入关键Css main.wxss icon.wxss

@import &#;colorui/main.wxss&#;;
@import &#;colorui/icon.wxss&#;;
@import &#;app.css&#;; /* 你的项目css */
....

从新项目开始

下载源码解压获得/template,复制/template并重命名为你的项目,导入到小程序开发工具既可以开始你的新项目了

  • 使用自定义导航栏

导航栏作为常用组件有做简单封装,当然你也可以直接复制代码结构自己修改,达到个性化目的。

App.js 获得系统信息

 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;
      }
    })
},

App.json 配置取消系统导航栏,并全局引入组件

&#;window&#;: {
	&#;navigationStyle&#;: &#;custom&#;
},
&#;usingComponents&#;: {
    &#;cu-custom&#;:&#;/colorui/components/cu-custom&#;
}

page.wxml 页面可以直接调用了

<cu-custom bgColor=&#;bg-gradual-pink&#; isBack=&#;{{true}}&#;>
	<view slot=&#;backText&#;>返回</view>
	<view slot=&#;content&#;>导航栏</view>
</cu-custom>

组件预览

  • 基础元素部分













  • 交互组件













  • 扩展插件






总结

以上就是几乎所有的ColorUI组件,感兴趣的可以直接查看官方demo,颜值相当高!enjoy it!

原文链接:,转发请注明来源!