0.0.1 • Published 3 years ago

element-vue v0.0.1

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

中后台页面组件

基于element-ui的二次封装

一、fd-form组件

1.Form Attributes

参数说明类型默认值
form见2.1表Array[]
hasControl控制按钮是否显示Boolertrue
sumbitText提交按钮显示文本String'提交'
resetText重置按钮显示文本String'重置'

2.Form Option

(2.1表)

参数说明类型默认值
title表单名称String-
key字段String-
type表单类型input、select、radio...Input
options表单为select、radio的时候用Array | {label: '表单', value: ''}
defaultValue默认值String | Number | Array
props接受element原始属性值Object{}
isRequired是否校验Boolerfalse
contentWidth文本宽度Number | String220px
rule校验规则Array | Object[] | {}

3.Form Events

事件名称说明参数
submitForm提交方法,接受两个参数。参数一form值,第二个参数校验值Function(data, valid)
<Fd-main :form="formData" @submit="onSubmit"></Fd-main>

onSubmit(data, valid) {
  // 接受两个参数:
  // data: 返回的formdata值 类型:Object
  // valid: 校验值 类型: Booler
 }

二、table组件

1.Aable Attributes

table列表接受两个属性值,一个为列表值,一个为配置值。

参数说明类型默认值
tableDatatable列表值Array
tableConfig列表配置项Array

2.tableConfig Attributes

参数说明类型默认值
key列表字段String''
title列表标题String''
props接受element原始属性值Object{}
format格式化时间的时候传递Boolertrue
renderrender函数进行渲染Function-
tableConfig: [
        { key: "date", title: "时间", props: { width: "180" }, format: true },
        { key: "name", title: "姓名", },
        { key: "address", title: "地区" },
    ]

3.Table-column Scoped Slot

通过 v-slot:name = { scope } 可以获取到 row, column, $index的数据,用法参考 demo。

注意:name就是key的值对应。

name说明默认值
key自定义列的内容,参数为 { row, column, $index }
<Fd-main :tableData="list" :tableConfig="tableConfig">
        <template v-slot:name="scope">{{ scope.row.name }}</template>
</Fd-main>

4.table使用render函数

参考Vue-render地址: 参考地址

参数一:render函数, 参数二:当前行值

 {
    title: '操作',
    render: (h, { row }) => {
         return h('el-button', {
            props: {
              type: 'primary'
            },
            on: {
              click: () => {
                this.onUpdate(row);
                },
              },
           domProps: {
              innerHTML: '操作',
             },
          });
     },
 },

三、Pagination 分页使用

Pagination Attributes

参数说明类型默认值
currentPage当前页码Number1
pageSize页数Number10
total总条数number-
pageSizes每页显示个数选择器的选项设置number | []10, 20, 30, 40, 50, 100

Pagination Events

事件名称说明回调函数
changeSizepageSize 改变时会触发size,formData
changePagecurrentPage 改变时会触发page, formData
<template> 
	<FdMain
      @changePage="changePage"
      :total="total"
      :currentPage="1"
      :pageSize="10"
    ></FdMain>
</template>

export default {
 methods: {
    changePage(page, form) { 
      // 接受两个参数
      //1. page 当前页码
      //2. form 表单数据
      console.log(page, form);
    },
  },
}
0.0.1

3 years ago

0.1.0

6 years ago