New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

element-table-plugin

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-table-plugin

基于Element,根据配置为网页添加表格

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

表格插件

基于Element,根据配置为网页添加表格

Features

  • 展示静态数据
  • 配置接口,自动请求,展示动态数据
  • 分页、换页
  • 统一的空数据时的展示效果
  • 固定列、排序、设置列的宽度、控制列的展示
  • 自定义列模板
  • 鼠标浮在单元格上,展示完整内容,支持一键复制

引入

// main.js

import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import elementTable from 'element-table-plugin'
import App from './App.vue'

Vue.use(ElementUI)
Vue.use(elementTable, { // 详见fields
  page: 'page',
  pageSize: 'limit',
  code: 'stat',
  apiSuccess: 1,
  data: 'data.list', // 取表格数据
  total: 'data.total', // 取总条数
})
// or
// Vue.use(elementTable)

new Vue({
  render: h => h(App),
}).$mount('#app')

// index.vue

<element-table
  :initRequest="request"
  :initColumns="columns"
  :canChangeColumns="canChangeColumns"
  :initPagination="pagination">
    <template #action="{row}">
      <span @click="edit(row)">编辑</span>
    </template>
</element-table>

<script>
export default {
  data () {
    return {
      request: {
        url: '/api/data/list',
        method: 'post',
      },
      columns: [
        {
          prop: 'name',
          label: '姓名',
          fixed: 'left',
          width: '280px',
        },
        {
          prop: 'desc',
          label: '描述',
          showOverflowPopover: true,
        },
        {
          prop: 'create_time',
          label: '创建时间',
          sortable: true,
        },
        {
          prop: 'action',
          label: '操作',
        }
      ],
      canChangeColumns: true,
      pagination: {
        pageSize: 20,
      },
    }
  },
  methods: {
    edit (row) {
      //
    },
  },
}
</script>

props

initRequest

  • 请求表身,与axios中的一致,支持异步传入

  • 类型:object

  • 默认值:{}

initFields

  • 字段集

  • 类型:object

  • 默认值:{}

  • 属性的列表:

参数说明类型required默认值
page当前页stringfalse-
pageSize每页条数stringfalse-
code状态码stringfalse-
apiSuccess成功的状态码的值numberfalse-
data表身stringfalse-
total总条目数stringfalse-

initColumns

  • 表头

  • 类型:Array<object>

  • 默认值:[]

  • 元素的属性的列表:

参数说明类型required默认值
prop列的prop,与Element中的一致stringtrue-
label列的label,与Element中的一致stringfalse-
align对齐方式,与Element中的一致stringfalse-
width列的宽,与Element中的一致stringfalse-
showOverflowPopover是否用浮层显示单元格的详情booleanfalse-
fixed固定列,与Element中的一致string | booleanfalse-
sortable是否支持排序booleanfalse-

initData

  • 表身,配了initRequest就不用传这个

  • 类型:Array<object>

  • 默认值:[]

initPagination

  • 分页

  • 类型:object

  • 属性的列表:

参数说明类型required默认值
page当前页numberfalse1
pageSize每页条数numberfalse30
total总条目数numberfalse0

maxHeight

  • 表格的最大高度,与Element中的一致

Methods

方法名说明
getFields返回表头和表身的数据

slot

name说明
列的prop自定义列的内容,参数为 { row }

Keywords

eleme

FAQs

Package last updated on 11 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts