1.0.1 • Published 7 years ago

rg-table v1.0.1

Weekly downloads
3
License
MIT
Repository
-
Last release
7 years ago

rg-table

基于regular的table组件,内部指定fetch进行数据请求,并且具备服务端分页、服务端搜索以及客户端全局搜索等功能,非常小巧和灵活。

安装

npm install --save-dev rg-table

BTW: 完美运行rg-table的前提需要regularlodashfont-awesome,apm-ui等环境支持。

Example

安装运行

npm install                         # 安装依赖
puer -a ./example/mock/data.js      # mock和静态服务器,前提安装有puer

数据测试:http://localhost:8000/api/blogs?limit=20&offset=0 页面访问:http://localhost:8000/example/index.html

API

Options

参数类型默认值数据流向描述
servicefunctionouter => innerfetch服务,用于异步请求数据
optionobjectouter => inner请求url、分页参数、扩展参数
option.limitnumber10outer => inner分页limit
option.offsetnumber0outer => inner分页offset
option.urlstringouter => inner请求url
option.{extends}stringouter => inner扩展参数
headersobjectouter => inner列表头信息
headers.titlestringouter => inner列表显示标题
headers.namestringouter => inner列表名称

示例:

this.data.service = fetchService;
this.data.option = {
  limit: 10,
  offset: 0,
  url: '/api/blogs'
};
this.data.header = [{
    title: "编号",
    name: "id"
  }, {
    title: '主题',
    name: 'title'
  }, {
    title: "时间",
    name: "time"
  }];

Methods

方法名称参数描述
refresh重置当前页,重新获取当前页数据
searchobject,例如{title:xx}服务器端请求搜索

示例:

this.$refs.list.search({title: this.data.title});