0


Color-UI 简介及使用教程

这是一个鲜亮的高饱和色彩,专注视觉的小程序组件库 。

ColorUI是一个css库!!!在你引入样式后可以根据class来调用组件,一些含有交互的操作我也有简单写,可以为你开发提供一些思路。需要你引入样式后可以根据class来调用使用。只需要在HTML或wxml标签中加入想要样式的class类名,就可以调用组件库中提前编辑好的样式,大大提高了开发效率。

ColorUI下载地址

使用:

  1. 1.原生微信小程序开发;
  1. 2.UniApp开发;

原生微信小程序开发

  • 已有项目

下载源码解压获得

  1. /demo

,复制目录下的

  1. /colorui

文件夹到你的项目的

  1. /miniprogram

下;

  1. App.wxss

引入关键Css

  1. main.wxss
  1. icon.wxss
  1. //App.wxss
  2. @import "colorui/main.wxss";
  3. @import "colorui/icon.wxss";
  4. ....

使用自定义导航栏

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

  1. App.js

获得系统信息

  1. //App.js
  2. onLaunch: function() {
  3. wx.getSystemInfo({
  4. success: e => {
  5. this.globalData.StatusBar = e.statusBarHeight;
  6. let custom = wx.getMenuButtonBoundingClientRect();
  7. this.globalData.Custom = custom;
  8. this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
  9. }
  10. })
  11. },
  1. App.json

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

  1. //App.json
  2. "window": {
  3. "navigationStyle": "custom"
  4. },
  5. "usingComponents": {
  6. "cu-custom":"/colorui/components/cu-custom"
  7. }
  1. page.wxml

页面可以直接调用了

  1. //page.wxml
  2. <cu-custom bgColor="bg-gradual-pink" isBack="{{true}}">
  3. <view slot="backText">返回</view>
  4. <view slot="content">导航栏</view>
  5. </cu-custom>

参数作用类型默认值bgColor背景颜色类名String''isBack是否开启返回BooleanfalseisCustom是否开启左侧胶囊BooleanfalsebgImage背景图片路径String''slot块作用backText返回时的文字content中间区域right右侧区域(小程序端可使用范围很窄!)

UniApp开发

  • 已有项目

下载源码解压获得

  1. /Colorui-UniApp

文件夹,复制目录下的

  1. /colorui

文件夹到你的项目根目录

引入关键Css文件

  1. main.css
  1. icon.css
  1. <style>
  2. @import "colorui/main.css";
  3. @import "colorui/icon.css";
  4. @import "app.css"; /* 你的项目css */
  5. /*.... */
  6. </style>

使用自定义导航栏

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

  1. App.vue

获得系统信息

  1. //App.vue
  2. onLaunch: function() {
  3. uni.getSystemInfo({
  4. success: function(e) {
  5. // #ifndef MP
  6. Vue.prototype.StatusBar = e.statusBarHeight;
  7. if (e.platform == 'android') {
  8. Vue.prototype.CustomBar = e.statusBarHeight + 50;
  9. } else {
  10. Vue.prototype.CustomBar = e.statusBarHeight + 45;
  11. };
  12. // #endif
  13. // #ifdef MP-WEIXIN
  14. Vue.prototype.StatusBar = e.statusBarHeight;
  15. let custom = wx.getMenuButtonBoundingClientRect();
  16. Vue.prototype.Custom = custom;
  17. Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
  18. // #endif
  19. // #ifdef MP-ALIPAY
  20. Vue.prototype.StatusBar = e.statusBarHeight;
  21. Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
  22. // #endif
  23. }
  24. })
  25. },
  1. pages.json

配置取消系统导航栏

  1. //pages.json
  2. "globalStyle": {
  3. "navigationStyle": "custom"
  4. },

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

使用封装,在

  1. main.js

引入

  1. cu-custom

组件。

  1. //main.js
  2. import cuCustom from './colorui/components/cu-custom.vue'
  3. Vue.component('cu-custom',cuCustom)
  1. page.vue

页面可以直接调用了

  1. //page.vue
  2. <cu-custom bgColor="bg-gradual-blue" :isBack="true">
  3. <block slot="backText">返回</block>
  4. <block slot="content">导航栏</block>
  5. </cu-custom>

参数作用类型默认值bgColor背景颜色类名String''isBack是否开启返回BooleanfalsebgImage背景图片路径String''slot块作用backText返回时的文字content中间区域right右侧区域(小程序端可使用范围很窄!)
知识分享还会持续更新,求关注~

标签: 前端 css css3

本文转载自: https://blog.csdn.net/interest_ing_/article/details/125730385
版权归原作者 爪爪蛙 所有, 如有侵权,请联系我们删除。

“Color-UI 简介及使用教程”的评论:

还没有评论