码迷,mamicode.com
首页 > 其他好文 > 详细

iview的table:自定义table表格中列头的标题和点击事件(renderHeader)

时间:2020-07-08 19:36:41      阅读:281      评论:0      收藏:0      [点我收藏+]

标签:lse   copy   bsp   spl   span   表格   sage   -o   sele   

 <Table
           class="table"
           :columns="columns1"
           :data="tableData"
           highlight-row
           :max-height="500"
           border
           @on-selection-change="onSelectionChange"
           @on-row-click="onRowClick"
    >
      <!-- 重量 -->
      <template slot-scope="{ row, index }" slot="weight">
        <Input v-model="tableData[index].weight" placeholder="请输入..." class="form-width" />
      </template>
    </Table>
 
 
columns1: [
          {
            title: ‘重量‘,
            slot: ‘weight‘,
            align: ‘center‘,
            key: ‘weight‘,
            renderHeader: (h, params)  => {
              return h(‘div‘,[
                h(‘span‘, {}, ‘重量‘),
                h(‘Icon‘, {
                  props: {
                    type: ‘ios-copy-outline‘,
                    size: ‘18‘
                  },
                  on: {
                    ‘click‘: (event) => {
                      this.weightCopy(event);
                    }
                  }
                })
              ])
            },
          }
        ],
 
  // 重量值拷贝功能
      weightCopy(e){
        if (this.tableData.length && this.tableData[0].weight) {
          this.tableData.map((item, index) => {
            this.tableData.splice(index, 1, {
              ...item,
              weight: this.tableData[0].weight
            })
          })
        } else {
          this.$Message.warning(‘第一行值为空,不能复制!‘)
        }
      },

iview的table:自定义table表格中列头的标题和点击事件(renderHeader)

标签:lse   copy   bsp   spl   span   表格   sage   -o   sele   

原文地址:https://www.cnblogs.com/wssdx/p/13268537.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!