zoukankan      html  css  js  c++  java
  • iview的table:自定义table表格中列头的标题和点击事件(renderHeader)

     <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('第一行值为空,不能复制!')
            }
          },
  • 相关阅读:
    ubuntu16.04安装破解pycharm
    python解压,压缩,以及存数据库的相关操作
    cocoapods Error
    swift项目导入OC框架
    实现全屏滑动返回效果
    Storyboard & XIB 自己的理解
    View & Controller 一些方法的执行顺序
    Touch ID 实现
    Apple Pay 初探
    ReactiveCocoa学习
  • 原文地址:https://www.cnblogs.com/wssdx/p/13268537.html
Copyright © 2011-2022 走看看