vxe-grid 实现下拉查看明细表格功能,主表、子表的功能。

1、先上一张图:

2、官方文档:Vxe Table v4.6

主要是二个属性:

type: expand

slots: {

    content: 'expandContent'

}

3、具体代码片段:

export const xzColumns: VxeGridPropTypes.Columns = [
  // {
  //   title: '',
  //   type: 'checkbox',
  //   fixed: 'left',
  //   width: '50',
  //   align: 'center',
  // },
  {
    title: '序号',
    type: 'seq',
    // fixed: 'left',
    width: '50',
    align: 'center',
    sortable: true,
  },
  {
    type: 'expand',
    width: '50',
    align: 'center',
    slots: {
      content: 'expandContent',
    },
  },

 ...
}
<template #expandContent="{ row, rowIndex }">
          <div class="expand-wrapper">
          这里是具体的内容
          </div>
</template>

4、通过上面的设置,就可以轻松实现主细表格。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 安装 vxe-table ``` npm install vxe-table --save ``` 2. 在 Vue 项目中引用 vxe-table ```javascript import Vue from 'vue' import 'xe-utils' import VXETable from 'vxe-table' import 'vxe-table/lib/style.css' Vue.use(VXETable) ``` 3. 在 Vue 模板中使用 vxe-table ```html <vxe-table :data="tableData" checkbox-config="{range: true}"> <vxe-table-column type="selection" width="60"></vxe-table-column> <vxe-table-column field="name" title="姓名"></vxe-table-column> <vxe-table-column field="age" title="年龄"></vxe-table-column> <vxe-table-column field="address" title="地址"></vxe-table-column> </vxe-table> ``` 4. 在 Vue 实例中定义数据 ```javascript export default { data() { return { tableData: [ { name: '张三', age: 20, address: '北京市' }, { name: '李四', age: 30, address: '上海市' }, { name: '王五', age: 40, address: '广州市' }, { name: '赵六', age: 50, address: '深圳市' } ] } } } ``` 5. 使用多选下框 ```html <template> <div> <vxe-dropdown ref="dropdown" v-model="value" :options="options" multiple> <template #option="{ option, $index }"> <vxe-checkbox :label="option.value" :content="option.label" :indeterminate="option.indeterminate" :checked="option.checked" @change="handleChange($event, option)"></vxe-checkbox> </template> </vxe-dropdown> <vxe-table :data="tableData" checkbox-config="{range: true}" ref="table"> <vxe-table-column type="selection" width="60"></vxe-table-column> <vxe-table-column field="name" title="姓名"></vxe-table-column> <vxe-table-column field="age" title="年龄"></vxe-table-column> <vxe-table-column field="address" title="地址"></vxe-table-column> </vxe-table> </div> </template> ``` ```javascript export default { data() { return { options: [ { label: '张三', value: '1' }, { label: '李四', value: '2' }, { label: '王五', value: '3' }, { label: '赵六', value: '4' }, ], value: ['1', '2'], tableData: [ { name: '张三', age: 20, address: '北京市' }, { name: '李四', age: 30, address: '上海市' }, { name: '王五', age: 40, address: '广州市' }, { name: '赵六', age: 50, address: '深圳市' } ] } }, methods: { handleChange (checked, option) { if (checked) { this.value.push(option.value) } else { const index = this.value.indexOf(option.value) if (index > -1) { this.value.splice(index, 1) } } } } } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值