1.0.4 • Published 5 years ago

vill-table v1.0.4

Weekly downloads
22
License
-
Repository
github
Last release
5 years ago

vill-table

a vue plugins about table

Build Setup

install the plugin on bash

npm install vill-table --save-dev

register the plugins on the vue project in the entry file (main.js)

import Table from 'vill-table'
Vue.use(Table);

on the vue template file ,you can use it by the follow example

<template>
    <div class="demo">
        <vill-table :columns="columns5" :data="data5"></vill-table>
    </div>
</template>

<script>
export default {
  data() {
    return {
      columns5: [
        {
          title: "Date",
          key: "date"
          // sortable: true
        },
        {
          title: "Name",
          key: "name"
        },
        {
          title: "Age",
          key: "age",
          sortable: true
        },
        {
          title: "Address",
          key: "address"
        },
        {
          title: "Action",
          key: "action",
          align: 'center',
          render: (h, params) => {
            return h(
              "div",
              {
                style: {
                  textAlign: params.align
                }
              },
              [
                h(
                  "Button",
                  {
                    props: {
                      type: "primary",
                      size: "small"
                    },
                    style: {
                      marginRight: "5px"
                    },
                    on: {
                      click: () => {
                        this.show(params.index);
                      }
                    }
                  },
                  "View"
                ),
                h(
                  "Button",
                  {
                    props: {
                      type: "error",
                      size: "small"
                    },
                    on: {
                      click: () => {
                        this.remove(params.index);
                      }
                    }
                  },
                  "Delete"
                )
              ]
            );
          }
        }
      ],
      data5: [
        {
          name: "John Brown",
          age: 18,
          address: "New York No. 1 Lake Park",
          date: "2016-10-03"
        },
        {
          name: "Jim Green",
          age: 24,
          address: "London No. 1 Lake Park",
          date: "2016-10-01"
        },
        {
          name: "Joe Black",
          age: 30,
          address: "Sydney No. 1 Lake Park",
          date: "2016-10-02"
        },
        {
          name: "Jon Snow",
          age: 26,
          address: "Ottawa No. 2 Lake Park",
          date: "2016-10-04"
        }
      ]
    };
  },
  methods: {
    remove(params) {
      console.log(params);
    },
    show(params) {
      console.log(params);
    }
  }
};
</script>

<style>
</style>

输入字段

字段说明类型默认值
columns表格头部数据--
data每一行数据--

columns属性

字段说明类型默认值
title表头title值String-
key表头title的唯一keyString-
sortable是否显示排序(true/false)Boolean-
render渲染函数Function可以自定义渲染内容

License

MIT

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago