2.6.6 • Published 5 years ago

vue-snb-table v2.6.6

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

English | 简体中文

vue-snb-table Table 表格

Table 表格. 用于展示多条结构类似的数据,可对数据进行排序操作。

GitHub stars Build Status GitHub issues GitHub forks GitHub last commit license NPM NPM

预览

https://cherislive.github.io/projrct/vue-snb-table/

页面预览: https://cherislive.github.io/projrct/vue-snb-table/

安装

$ npm install vue-snb-table

Import

Import using module

Import components to your project:

// in ES6 modules
import { SnbTable, SnbTableColumn, SnbTableHeader } from 'vue-snb-table';

// in CommonJS
const { SnbTable, SnbTableColumn, SnbTableHeader } = require('vue-snb-table');

// in Global variable
const { SnbTable, SnbTableColumn, SnbTableHeader } = VueSnbTable;

And register components:

Vue.component('snb-table', SnbTable);
Vue.component('snb-table-column', SnbTableColumn);
Vue.component('snb-table-header', SnbTableHeader);

Import using script tag

<script src="../node-modules/vue-snb-table/dist/index.js"></script>
const SnbTable = VueSnbTable.SnbTable;
const SnbTableColumn = VueSnbTable.SnbTableColumn;
const SnbTableHeader = VueSnbTable.SnbTableHeader;

new Vue({
  el: 'body',
  components: {
    'snb-table': SnbTable,
    'snb-table-column': SnbTableColumn,
    'snb-table-header': SnbTableHeader
  }
});

Usage

Work on a Vue instance:

<SnbTableHeader
  :columns="columns" 
  :colsWidth="colsWidth" 
/>
<snb-table>
  <snb-table-column prop="data1" label="data1" />
  <snb-table-column prop="data2" label="data2" />
  <snb-table-column prop="data3" label="data3">
    <template slot-scope="scope">{{scope.data3}}</template>
  </snb-table-column>
</snb-table>

Table

Attributes

OptionTypeDescriptionAccepted ValuesDefault
dataArray显示的数据。--
showHeaderBoolean是否显示表头。-true
headerFixedObject固定表头。state: true/falsenull
defaultSortObject默认的排序列的 prop 和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序order: asc, desc如果只指定了prop, 没有指定order, 则默认顺序是ascending
sortStateObject可以通过该属性设置排序列的 prop 和顺序。它的prop属性指定排序的列,order指定默认排序的顺序order: asc, desc-
headerColsWidthArray表头各个列宽。--

Events

Event NameDescriptionparams
columnsReady当表格的列的数据状态加载完成的时候会触发该事件,该事件用于自定义表头的情况。columns
sortChange当表格的排序条件发生变化的时候会触发该事件。{sort: {prop, order}, column}
colsWidth当表格的数据发生变化的时候会触发该事件,返回各个列宽。widths
distanXChange当拖动表格横向滚动的时候会触发该事件。width
rowClick当某一行被点击时会触发该事件。row

Table-column

Attributes

OptionTypeDescriptionAccepted ValuesDefault
propString对应列内容的字段名,也可以使用 property 属性。--
labelString显示的标题。--
alignString对齐方式。left/center/rightleft
widthString对应列的宽度。--
fixedString列是否固定在左侧。true, falsefalse
sortableBoolean对应列是否可以排序。true, falsefalse
formatterFunction(row, column, cellValue, index)用来格式化内容。--

Table-header

Attributes

OptionTypeDescriptionAccepted ValuesDefault
columnsArray各个列属性。--
colsWidthArray各个列宽。--
distanXNumber表格横向滚动的距离。left/center/rightleft
defaultSortObject默认的排序列的 prop 和顺序。它的prop属性指定默认的排序的列,order指定默认排序的顺序order: asc, desc如果只指定了prop, 没有指定order, 则默认顺序是ascending
sortStateObject可以通过该属性设置排序列的 prop 和顺序。它的prop属性指定排序的列,order指定默认排序的顺序order: asc, desc-

Events

Event NameDescriptionparams
sortChange当表格的排序条件发生变化的时候会触发该事件。{sort: {prop, order}, column}
headerColsWidth表头各个列宽。当表格的渲染完成的时候会触发该事件。widths

Development

Watching with hot-reload:

$ npm run dev

Develop on real remote device:

$ npm run remote-dev {{ YOUR IP ADDRESS }}

License

MIT

2.6.6

5 years ago

2.6.5

5 years ago

2.6.4

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago