Giter VIP home page Giter VIP logo

vue-free-table's Introduction

vue-free-table

基于 element ui table 二次封装,几乎支持原 table 所有的功能

文档使用

DEMO预览

特性

  • 以 element-ui table 为基础进行二次封装,减少代码量
  • 继承 element-ui table 组件的参数及事件
  • 支持render渲染
  • 支持slot插槽
  • 支持组件引入
  • 支持树形数据
  • 支持分页功能

文档

属性 说明 类型 默认
data table 的 data 属性 Array []
column 用于控制表格列渲染 Array []
columns-props 用于定义所有 column 公共的属性 Object
pagination 是否显示分页组件, 具体详细请看pagination配置栏目 Boolean false

只是在 Element Table 封装了一层,原本设置在 Table 上的 props 与事件监听和设置都可以直接绑定到组件上,具体配置可参考Element Tabel 文档

column 配置 column 用于控制表格的列行为, 设置示例:

const column = [
  { label: '日期', prop: 'date', width: 100 },
  { label: '姓名', prop: 'name' },
  { label: '邮编', prop: 'zip' },
  {
    label: '地址',
    prop: 'address',
    render: (h, scope) => {
      return (<el-tag>{scope.row.address}<el-tag>)
    }
  },
  {
    label: '组件',
    prop: 'cmp',
    component: EditBtn,
    listeners: {
      'row-edit'(row) {
        console.log('row-edit', row)
      }
    }
  }
]

columns-props配置 columns-props用于配置 columns 各列默认的 props 属性,

const columnsProps ={
  align: 'left',
  minWidth: 120
}

pagination配置 pagination用于控制显示分页组件, pagination分页组件是继承el-pagination的二次封装,来源开源项目中的vue-element-admin 组件库中分页组件

参数 说明 类型 默认值
total 总条目数 Number /
page 当前页数 支持 .sync 修饰符 Number 1
limit 每页显示条目个数,支持 .sync 修饰符 Number 20
page-sizes 每页显示个数选择器的选项设置 Number[] [10, 20, 30, 50]
hidden 是否隐藏 Boolean false
auto-scroll 分页之后是否自动滚动到顶部 Boolean true

其它 Element 的 el-pagination支持的属性,它也都支持。详情见文档

示例

<template>
  <free-table border stripe :data="data" :column="column"></free-table>
</template>

<script>
import FreeTable from '@/components/FreeTable'

export default {
  components: {
    FreeTable
  },
  data() {
    return {
      column: [
        { label: '日期', prop: 'date' },
        { label: '姓名', prop: 'name' },
        { label: '省份', prop: 'province' },
        { label: '市区', prop: 'city' },
        { label: '地址', prop: 'address' }
      ],
      data: [
        {
          date: '2016-05-03',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄'
        },
        {
          date: '2016-05-02',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄'
        }
      ]
    }
  }
}
</script>

构建命令

# 安装依赖包
npm install

# 启动开发环境
npm run serve

# 构建生产环境
npm run build

# 启动unit测试
npm run test:unit

# 启动unit end-to-end 测试
npm run test:e2e

# 检查修复代码
npm run lint

vue-free-table's People

Contributors

scarecrowdu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-free-table's Issues

建议

你好,考虑增加拖拽功能么 表头和数据的 重排序

render v-model

使用 render渲染的时候 input 无法使用v-model

建议

hi, 作者你好,过去一段时间在搭建一套vue-pro-component,非常感谢你提供了这么好的案例。目前已经初步完成了 pro-form|pro-table|pro-search|pro-dialog|pro-search-table|pro-dialog-form 的开发。能够极大的提升使用vue 开发中后台项目的效率,只需要100行代码,就可完成增删改查,批量修改等操作,希望能加个联系方式交流😊

建议

请问一下作者 多级表头 如何实现

table-column minWidth

{ label: '序号', type: 'index', minWidth: 100 }

这个100 是像素还是百分比啊 设置后显示不对啊 其他列宽度都是自适应 某一列设置最小宽度 但是 宽度够的时候 这一列占的位置特别大

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.