0.0.1-d • Published 5 years ago

wh-table-group v0.0.1-d

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

my-table

A Vue.js project

Preview

# clone
git clone git@github.com:stack-wuh/my-table.git

cd example

npm install

npm run dev

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

For detailed explanation on how things work, consult the docs for vue-loader.

使用

WTable

Props

参数说明类型默认值
header是否展示Table的header部分Booleantrue
footer是否展示Table的Footer部分Booleantrue
columns提供迭代的TableColumn的列表Array[]
dataTable的元数据Array[]
border是否展示Table的边框Booleantrue
stripe是否Table的斑马纹Booleantrue
isShowPrefix是否展示表格第一列的功能列Booleantrue
textAlign对齐的位置Stringcenter

Events

按钮点击或者其他事件全部由v-on代理了, 使用了MySearchButtonGroup组件, 具体上传的事件名全部通过ref属性自定义, 使用方法如下:

import WTable from 'wh-table'
Vue.use(WTable)

const btns = { text: 'down', ref: 'down' }, { text: 'search', ref: 'search' }, { text: 'any', ref: 'any' }

```html
  <w-table
    @down="handleDown"
    @search="handleSearch"
    @any="handleAny">
  </w-table>

Slot

name说明
header表格Header区域
footer表格的footer区域

WTabelHeader

Props

参数说明类型默认值
name表格左上角的文本Stringnone

Slot

name说明
right为表格Header区域预留了功能区域, 可以在这里添加按钮或者是表单, 推荐搭配MySearchGroup组件使用

WTableColumn

由自定义JSON文件迭代渲染, 使用如下:

const List = [
  {
    label: '姓名',
    field: 'name',
    type: ['default', undefined, null], // 以上三种情况可以不填
  },
  {
    label: 'XXX',
    field: 'custom',
    type: 'image'
  },
  {
    label: 'XXX',
    field: 'custom',
    type: 'switch',
  },
  {
    label: 'XXX',
    field: 'custom',
    type: 'tag',
    transfer: {
      value1: mapValue1,
      value2: mapValue2
    },
    types: {
      value1: 'success',
      value2: 'info'
    }
  },
  {
    label: 'XXX',
    field: 'custom',
    type: 'component',
    component: VueComponent
  },
  {
    label: 'XXX',
    type: 'button',
    list: [
      {
        text: 'up',
        ref: 'up'
      },
      {
        text: 'down',
        ref: 'download'
      }
    ]
  }
]

type == default, null, undefined

参数说明
default只能渲染普通文本

type == image, images

参数说明
image只能渲染一张图片, 如: { url: 'https:www.baidu.com' }
images可以渲染多张图片, 期待后台返回一个数组, 如: { url: '/image1.png', '/imgs2.png' }

type == switch

参数说明
switch使用element的Switch组件, 一个双向开关, 属性同element

type == tag

参数说明
tag用于多状态枚举, 后台返回值需要前端映射, 提供一个transfer对象用于渲染, types对象用于绑定展示type

type == component

参数说明
component使用Vue中的Component标签, 自定义满足需求的组件, 组件声明如下
const VueComponent = {
  props: ['scope'],
  template: `
    <div class="wrap">{{scope}}</div>
  `
}
const List = [
  {
    label: 'aaa',
    type: 'component',
    component: VueComponent
  }
]
  <component :is="List.component" v-bind="List" :scope="List"></component>

type == button

搭配MySearchButtonGroup 使用

0.0.1-d

5 years ago

0.0.1-c

5 years ago

0.0.1-b

5 years ago

0.0.1-a

5 years ago

0.0.1

5 years ago