1.1.3 • Published 3 years ago

cre-ui v1.1.3

Weekly downloads
89
License
-
Repository
-
Last release
3 years ago

cre-ui 文档

版本:v-1.0.26

一、组件库介绍

组件库地址: https://www.npmjs.com/package/cre-ui

组件库 cre-ui 基于 Vue2.6.11 实现。组件库的使用分为全量引入按需引入两种方式。

  • 组件库安装
npm i cre-ui --save
  • 全量引入
import Vue from "vue";
import CreUi from "cre-ui";
// 需引入全局样式表
import "cre-ui/lib/theme-chalk/index.css";

Vue.use(CreUi);
  • 按需引入
import Vue from "vue";
import { Component1, Component12, Component3 } from "cre-ui";
// 按需引入样式
import "cre-ui/lib/theme-chalk/component1.css";
// ...

const components = [Component1, Component12, Component3];
components.forEach((component) => {
  Vue.use(component);
});

二、组件详情

组建名称均以 cre-开头,使用规则类似 element-ui。

1. IePage

不兼容 ie 浏览器环境时展示页面

例:

<cre-ie-page
  content-text="网站暂时不支持IE浏览器,请改用其他浏览器访问。"
  content-tip="我是提示信息"
  logo="http://mall-dev.crealitygroup.com/_nuxt/img/29dc86f.png"
  content-foot="我是底部版权信息"
  theme-color="#cca558"
  content-bg="http://pic-cdn-dev.creality.com//iePageIcon/ie-title-icon-2.png"
/>

IePage效果图

IePage Attributes

参数说明类型可选值默认值
content-text错误主要内容(必填)Sring----
content-tip提示信息Sring----
logologo 完整路径Sring----
content-foot底部版权信息Sring----
theme-color主题色Sring--#42bdd8
content-bg主要提示内容背景图Sring--http://pic-cdn-dev.creality.com//iePageIcon/ie-title-icon-2.png

2. Pagination

分页组件

例:

<cre-pagination
  :page="1"
  :page-size="10"
  :total="100"
  :hide-on-single-page="true"
/>

Pagination效果图

Pagination Attributes

参数说明类型可选值默认值
page页码Number--1
page-size每页数据条数Number--20
total数据总条数Number--0
hide-on-single-page是否在只有一页时隐藏Booleantrue/falsetrue

Pagination Event

事件名称说明回调参数
pageChange页码变化时触发当前页码 page 的值

3. ImageZoom

图片放大组件,若指定 video-src 属性可播放视频

例:

<cre-image-zoom
  url="http://pic-cdn-dev.creality.com/vip_mall/2d1aae3d-fb6c-4570-8782-9af131692f37"
  :cale="2"
  :scroll-disabled="true"
  video-src="http://video-cdn-dev.creality.com/vip_mall/cb262684-a211-4c07-a759-e90f9a64eb13"
  width="400"
  height="400"
/>

ImageZoom效果图

ImageZoom Attributes

参数说明类型可选值默认值
url图片完整路径String----
big-url放大后显示的图片String--默认等于 url 的值
scale放大倍数Number--1.5
scroll-disabled放大时是否禁用页面滚动Booleantrue/falsefalse
video-src视频完整路径String----
width图片宽度String/Number--500
height图片高度String/Number--500

4. Timer

倒计时组件,样式需要自定义

例:

<cre-timer :init-time="120" :locale="en" />

Timer效果图(中文)Timer效果图(英文)

Timer Attributes

参数说明类型可选值默认值
init-time计时秒数(必填)Number----
locale语言Stringzh / enzh

Timer Event

事件名称说明回调参数
timerEnd倒计时结束时触发--

5. BackTop

回到顶部按钮

例:

<cre-back-top />

BackTop效果图

BackTop Attributes

参数说明类型可选值默认值
edge页面滚动距离占页面总高度比例的边界值Number--0.5
right按钮与页面右边缘的距离String/Number--100
bottom按钮与页面下边缘的距离String/Number--180

6. Comment

评论组件

例:

<cre-comment-item :user-info="userInfo" :comment="comment" />

Comment效果图

Comment Attributes

参数说明类型可选值默认值
comment评论对象,包含: 内容 (string) content,图片(array) pictures,规格 (array) skuList,时(number) createTimeObject: { content: ”“, Pictures: [], skuList: {key:'',value:''}, createTime: }----
userInfo发表人{ nickName,avatar,userId }Object----
locale语言Stringzh / enzh

Comment Slot

name说明
createTime评论时间: 默认以 2004-09-11 00:00:00输出
rotateLeft大图左旋转图标
rotateReft大图又旋转图标

7. Collapse

大下拉框组件

例:

<cre-collapse width="300" height="300" trigger="hover">
  <template slot="entry">
    <el-button>我是按钮</el-button>
  </template>
  <template slot="body">
    <div>我是下拉框内容</div>
  </template>
</cre-collapse>

Collapse效果图

Collapse Attributes

参数说明类型可选值默认值
width下拉框宽度Number/String--200
height下拉框高度Number/String--200
trigger触发方式Stringhover/clickhover
placement显示位置Stringleft/rightleft
angle-space尖角离边缘距离Number/String--24

Collapse Slots

name说明
entry下拉框所挂载的元素,通常为按钮
body下拉框内容容器

Collapse Events

事件名称说明回调参数
onOpen下拉框展开时触发--
onClose下拉框收起时触发--

8. TagList

标签列表

例:

<cre-tag-list :tag-list="tagList" @tagClick="tagClick" />

TagList Attributes

参数说明类型可选值默认值
label标签label文本String--大家都在说:
tagList包含id, name属性的标签列表Array--[]
activeId被选中的标签id(默认列表第一个为选中)Number----

TagList Attributes | 事件 | 说明 | 回调参数 | | ----- | ---- | ------ | | tagClick | 点击标签回调 | tag对象 |

9. Input

输入框

例:

<cre-input v-model="inputValue" :width="200" />
参数说明类型可选值默认值
value/v-model绑定输入值String/Number----
width宽度String/Number--600
placeholder提示文字String--请填写内容
maxlenghth最大输入字符串长度Number--100
type原生输入类型Stringtext/number/passwordtext
disabled是否禁用Booleantrue/falsefalse
readonly是否只读Booleantrue/falsefalse

Input Event

事件说明回调参数
change输入时触发当前输入值

10. Textarea

文本域

例:

<cre-textarea v-model="textAreaValue" width="500" rows="4" />

Textarea Attributes

参数说明类型可选值默认值
value/v-model绑定输入值String----
placeholder提示文字String--请填写内容
width宽度String/Number--600
rows行数Number--5
maxlenghth最大输入长度Number--200
disabled是否禁用Booleantrue/falsefalse
readonly是否只读Booleantrue/falsefalse
resize是否可改变大小Booleantrue/falsefalse

Textarea Event

事件说明回调参数
change输入时触发当前输入值

11. Select

选择框

例:

<cre-select
  v-model="selectValue"
  :options="selectOptions"
  filterable
  clearable
  @change="selectChange"
/>

Select Attributes

参数说明类型可选值默认值
value/v-model绑定选中值String/Number----
options选项列表Array(包含 {label, value})----
width宽度String/Number--500
placeholder提示文字String--请选择
clearable是否可清空选项Booleantrue/falsefalse
disabled是否禁用Booleantrue/falsefalse
nameinput原生name属性String----
filterable是否可搜索Booleantrue/falsefalse
filterMethod自定义搜索方法Function--undefined
loading是否在加载中Booleantrue/falsefalse
noMatchText搜索条件无匹配时显示的文字String--无匹配数据
defaultFirstOption在输入框按下回车,选择第一个匹配项。需配合 filterable 使用Booleantrue/falsefalse
popperAppendToBody是否将弹出框插入至 body 元素Booleantrue/falsefalse
automaticDropdown对于不可搜索的 Select,是否在输入框获得焦点后自动弹出选项菜单Booleantrue/falsefalse

Select Event

事件说明回调参数
change选中选项时触发当前选项option的value值

12. Checkbox

复选框

例:

<cre-checkbox
  v-model="checkboxValue"
  label="我是Checkbox"
  type="box"
  @change="handleCheckboxChange"
/>

Checkbox Attributes

参数说明类型可选值默认值
value/v-model绑定值Booleantrue/falsefalse
label文字String----
typeUI类型Stringnormal/boxnormal

Checkbox Event

事件名称说明回调参数
change切换选中状态时触发当前是否选中

13. CheckboxGroup

复选框组

例:

<cre-checkbox-group
  v-model="checkboxGroupValue"
  :options="checkboxGroupOptions"
  @change="handleCheckboxGroupChange"
/>

按需引入样式依赖:

@import 'cre-ui/lib/theme-chalk/checkbox.css'

CheckboxGroup Attributes

参数说明类型可选值默认值
value/v-model绑定值,选中选项的value列表Array(元素为String/Number)aa[]
options选项列表Array(元素为{label, value})aa[]

CheckboxGroup Event

事件名称说明回调参数
change切换选中状态时触发当前选中选项的value列表

14. RadioGroup

单选按钮组

例:

<cre-radio-group v-model="radioValue" :options="radioOptions" />

RadioGroup Attributes

参数说明类型可选值默认值
value/v-model绑定值,选中选项的valueString/Number----
options选项列表Array(元素为{label, value})--[]

RadioGroup Event

事件名称说明回调参数
change切换选项时触发当前选中选项的value

15. Datepicker

日期选择

例:

<cre-datepicker
  :value.sync="dateValue"
  @change="handleDatepickerChange"
/>

按需引入样式依赖:

@import 'cre-ui/lib/theme-chalk/select.css'

Datepicker Attributes

参数说明类型可选值默认值
value日期绑定值,需要自动同步需要加syncObject({ year, month, date })----

Datepicker Event

事件名称说明回调参数
change年/月/日选中项变化时触发当前选中日期

16. Image

图片展示

例:

<cre-image
  src="http://pic-cdn-dev.creality.com/vip_mall/03218e36-9feb-4662-8a89-83533b6af5f7"
  width="200"
  height="200"
/>

Image Attributes

参数说明类型可选值默认值
src图片地址String----
width图片宽度String/Number--80
height图片高度String/Number--80
fit确定图片如何适应容器框,同原生 object-fitStringfill / contain / cover / none / scale-downcover
alt原生altString----
lazy是否开启懒加载Booleantrue / falsefalse
scrollContainer开启懒加载后,监听 scroll 事件的容器。String/HTMLElement--最近一个 overflow 值为 auto 或 scroll 的父元素
defaultSrc占位图片地址String----
errorSrc加载失败时图片地址String----

17. ImagesPreview

图片放大预览组件

例:

<cre-images-preview
  :image-list="[
    'http://pic-cdn-dev.creality.com/vip_mall/20c1336c-6a64-4ab7-8833-b06496ebee31',
    'http://pic-cdn-dev.creality.com/vip_mall/f00d9e5d-307d-47eb-a7da-b4f4e54644fa'
  ]"
/>

Image Attributes

参数说明类型可选值默认值
imageList图片地址列表Array--[]
imageSize展示图片大小(像素)String / Number--140
previewSize放大图片大小(像素)String / Number--400
locale语言Stringzh / enzh

18. ImageUpload

图片上传

例:

<cre-image
  src="http://pic-cdn-dev.creality.com/vip_mall/03218e36-9feb-4662-8a89-83533b6af5f7"
  width="200"
  height="200"
/>

按需引入样式依赖:

@import 'cre-ui/lib/theme-chalk/image.css'

ImageUpload Attributes

参数说明类型可选值默认值
limit最大上传文件数Number--3
sizeLimit上传文件大小限制Number--5 1024 1024
imageSize展示图片大小String / Number--80
previewSize放大预览图大小String / Number--600
locale语言Stringzh / enzh

ImageUpload Event

事件名称说明回调参数
onFilesChange文件列表变化时触发当前选中图片的文件列表

19. Dialog

弹窗组件

例:

<cre-dialog
  :visible.sync="addressDialogVisible"
  width="659"
  height="511"
  title="添加收货地址"
  confirm-button-text="保存新地址"
  button-width="160"
  button-height="48"
/>

Dialog Attributes

参数说明类型可选值默认值
visible是否显示Booleantrue / falsefalse
title标题String--提示
width宽度String / Number--520
height高度String / Number--280
buttonWidth按钮宽度String / Number--88
buttonHeight按钮高度String / Number--36
confirmButtonText确定按钮文字String--确定
cancelButtonText取消按钮文字String--取消

Dialog Slot

name说明
body窗口中的内容

Dialog Events

事件名称说明回调参数
confirm点击确定按钮时触发--
cancel点击取消按钮时触发--

20. MessageDialog

消息弹窗

例:

<cre-message-dialog
  :visible.sync="messageDialogVisible"
  title="我是提示标题"
  message="我是提示信息"
/>

按需引入样式依赖:

@import 'cre-ui/lib/theme-chalk/dialog.css'

MessageDialog Attributes

参数说明类型可选值默认值
visible是否显示BooleanTrue / falsefalse
title标题String--提示
message信息内容String----
confirmButtonText确定按钮文字String--确定
cancelButtonText取消按钮文字String--取消

MessageDialog Events

事件名称说明回调参数
confirm点击确定按钮时触发--
cancel点击取消按钮时触发--

21. Message

顶部弹出提示

引入:

import Vue from 'vue'
import { Message } from 'cre-ui'

Vue.prototype.$message = Message

使用:

// 钩子函数中
this.$message.info('提示信息')
this.$message.warning('警告信息')
this.$message.success('成功信息')
this.$message.error('错误信息')

22. Breadcrump

面包屑

例:

<cre-breadcrump
  :list="[
    { name: '首页', path: '/index' },
    { name: '个人订单', path: '/my-orders' },
    { name: '确认收货', path: '/receive' }
  ]"
/>

Breadcrump Attribute

参数说明类型可选值默认值
list面包屑列表Array (元素为{ name, path, newTab })newTab: true/false 是否打开新标签页[]

附录 项目维护相关

Project setup

npm install

cd .\packages\theme-chalk

npm install

cd ..\..\

Compiles and hot-reloads for development

npm run serve

打包

整体打包
npm run dist
清理旧版本打包文件
npm run clean

生成 src/index.js 文件

npm run build:file

打包样式文件

npm run build:theme

Lints and fixes files

npm run lint
1.1.3

3 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.20

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.12

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago