0.1.7 • Published 4 years ago

olvue-ui v0.1.7

Weekly downloads
32
License
-
Repository
-
Last release
4 years ago

效果演示

  • 初始化vue项目: vue create demo
  • 安装组件库: npm install olvue-ui
  • 由于该组件库是使用sass编写的,因此还需要安装:npm install sass sass-loader
  • 导入方式有两种选择:
    1. 全局导入:在main.js写下以下内容:
import Vue from 'vue'
import OlUI from 'olvue-ui'
Vue.use(OlUI)

以上代码已经完成了olvue-ui的导入。 2. 组件按需导入:若你只是希望引入部分组件,比如Button和Input,那么只需要在main.js中写下以下内容:

import Vue from 'vue'
import { OlButton, OlInput } from 'olvue-ui'
Vue.use(OlButton)
Vue.use(OlInput)

目录说明

  • components: olvue-ui组件库的自定义的组件
  • examples/main.js: 项目的主入口
  • examples/views: 所有自定义组件的demo
  • package: 发布到npm包的内容
  • .babelrc: 组件按需导入需要配置的文件
  • vue.config.js: 发布到npm修改webpack配置的文件

ol组件库

仿element ui组件库。实现的组件有ol-button ol-checkbox ol-checkbox-group ol-dialog ol-form ol-form-item ol-input ol-radio ol-radio-group ol-switch ol-row ol-col ol-date-picker

布局

Attributes

参数说明类型可选值默认值
gutter栅栏间隔number0
span栅栏占据的列数number24
offset栅格左侧的间隔格数number0
type布局模式,可选flexstring
justifyflex 布局下的水平排列方式stringstart/end/center/space-around/space-betweenstart

基本结构

  • 基础布局
  • 分栏间隔
  • 混合布局
  • 分栏偏移
  • flex布局

button组件

Attributes

参数说明类型可选值默认值
type类型stringprimary / success / warning / danger / info / textdefault
plain是否朴素按钮booleanfalse
round是否圆角按钮booleanfalse
circle是否圆形按钮booleanfalse
disabled是否禁用状态booleanfalse
icon图标类型string

事件

事件名事件描述
click点击事件

基本结构

<ol-button @click="fn">默认</ol-button>
<ol-button type="primary">主要</ol-button>
<ol-button type="success">成功</ol-button>
<ol-button type="warning">警告</ol-button>
<ol-button type="danger">危险</ol-button>
<ol-button type="info">信息</ol-button>
<ol-button type="default">信息</ol-button>

dialog组件

Attributes

参数说明类型默认值
title对话框标题string提示
width对话框宽度string50%
top与顶部的距离string15vh
visable是否显示dialog(支持sync修饰符)booleanfalse

事件

事件名事件描述
opened模态框显示
closed模态框关闭

插槽说明

插槽名称插槽描述
title模态框标题
default模态框内容
footer模态框的底部操作区

基本结构

<ol-button type="primary" @click="visible=true">点击显示对话框</ol-button>
<ol-dialog width="20%" top="100px" :visible.sync="visible">
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
  </ul>
  <template v-slot:footer>
    <ol-button type="primary" @click="visible=false">确认</ol-button>
    <ol-button @click="visible=false">取消</ol-button>
  </template>
</ol-dialog>

input组件和textarea组件

Attributes

参数说明类型可选值默认值
type类型stringtext / password / textareatext
namename属性string
placeholder占位符string
clearable是否显示清空按钮booleanfalse
show-password是否显示密码切换按钮booleanfalse
disabled是否禁用状态booleanfalse

Attributes--TextArea

参数说明类型可选值默认值
type类型stringtextareatext
namename属性string
placeholder占位符string
disabled是否禁用状态booleanfalse
rows原生textarea属性string1
autosize可自适应文本高度的textareabooleanfalse

事件

事件名事件描述
focus获取焦点事件
blur失去焦点事件
change内容改变事件

基本结构

<ol-input type="text" name="username" placeholder="请输入姓名" v-model="username" />

<ol-input type="textarea" name="username" placeholder="请输入姓名" rows=3 />

<ol-input type="textarea" name="username" placeholder="请输入姓名" autosize />

switch组件

Attributes

参数说明类型默认值
v-model双向绑定booleanfalse
namename属性stringtext
activeColor自定义激活的颜色string-
inactiveColor自定义不激活的颜色string-

事件

事件名事件描述
changechange时触发的事件

基本结构

<ol-switch v-model="active" name="name" active-color="yellow" inactive-color="red" />

radio组件

Attributes

参数说明类型默认值
v-model双向绑定string / number / boolean-
namename属性string-
labelRadio的value值string / number / boolean-

radiogroup组件

Attributes

参数说明类型默认值
v-model双向绑定--

基本结构

<!-- radio组件 -->
<ol-radio label="1" v-model="gender">男</ol-radio>
<ol-radio label="0" v-model="gender">女</ol-radio>
<ol-radio label="1" v-model="gender"></ol-radio>
<ol-radio label="0" v-model="gender"></ol-radio>

<!-- radioGroup组件 -->
<ol-radio-group v-model="gender">
  <ol-radio label="1">男</ol-radio>
  <ol-radio label="0">女</ol-radio>
</ol-radio-group>

checkbox组件

Attributes

参数说明类型默认值
value单个checkbox的绑定booleanfalse
namename属性string-
labelcheckbox的value值string / number / boolean-

checkboxgroup组件

Attributes

参数说明类型默认值
v-model双向绑定--

基本结构

<ol-checkbox v-model="active">是否选中</ol-checkbox>
<ol-checkbox v-model="active"></ol-checkbox>

<ol-checkbox-group v-model="fruit">
  <ol-checkbox label="苹果"></ol-checkbox>
  <ol-checkbox label="香蕉"></ol-checkbox>
  <ol-checkbox label="橙子"></ol-checkbox>
</ol-checkbox-group>

form组件

Attributes

参数说明类型默认值
model表单数据对象object-
labelWidth表单域标签的宽度string-

form-item组件

Attributes

参数说明类型默认值
label标签文本string-

基本结构

<!-- form组件 -->
<ol-form :model="formData" label-width="100px" :rules="rules">
  <ol-form-item label="用户名" prop="name">
    <ol-input placeholder="请输入用户名" v-model="model.username"></ol-input>
  </ol-form-item>
  <ol-form-item label="邮箱" prop="email">
    <ol-input placeholder="请输入邮箱" v-model="model.email"></ol-input>
  </ol-form-item>
  <ol-form-item label="性别">
    <ol-radio-group v-model="gender">
      <ol-radio label="1">男</ol-radio>
      <ol-radio label="0">女</ol-radio>
    </ol-radio-group>
  </ol-form-item>
</ol-form>

ol-date-picker日期选择器组件

Attributes

参数说明类型默认值
v-model双向绑定string-

自动显示当前日期,点击即可选择日期。

基本结构

<!-- form组件 -->
<ol-date-picker v-model="now"></ol-date-picker>
<script>
  data: {
    return {
      now: new Date()
    }
  }
</script>
0.1.7

4 years ago

0.1.6

4 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago