iview表单render使用

使用:

<Table border ref="selection" :columns="columns" :data="listData" :loading="false"></Table>
复制代码

设置:

columns: [
    {
      type: 'selection',
      width: 60,
      align: 'center'
    },
    {
      title: '排序值',
      key: 'sortOrder',
      align: 'center'
    },
    {
      title: '品牌链接',
      key: 'siteUrl',
      align: 'center',
      render: (h, params) => {
        return h('a', {
          attrs: {
            href: params.row.siteUrl,
          },
          class:{
            siteUrl: true,
          }
        }, params.row.siteUrl);
      }
    },
    {
      title: '操作',
      align: 'center',
      render: (h, params) => {
        let row = params.row;
        return h('div', [
          h('Button', {
            props: {
              type: 'ghost',
              size: 'small'
            },
            style: {
              marginRight: '5px'
            },
            on: {
              click: () => {
                this.toCheckDetails(row.id);
              }
            }
          }, '查看'),
          h('Button', {
            props: {
              type: 'ghost',
              size: 'small'
            },
            style: {
              marginRight: '5px'
            },
            on: {
              click: () => {
                this.toEdit(row.id);
              }
            }
          }, '编辑')
        ]);
      }
    }
  ]
复制代码

属性大全:

render: (h, params) {//params是一个对象,包含 row、column 和index,分别指当前行数据,当前列数据,当前行索引
  return h('div', {
    props: { // Component props
      msg: 'hi',
    },
    
    attrs: { // normal HTML attributes
      id: 'foo'
    },
    
    domProps: { // DOM props
      innerHTML: 'bar'
    },
    
    on: { // Event handlers
      click: this.clickHandler
    },
    // For components only. Allows you to listen to native events, rather than events emitted from the component using vm.$emit.
    nativeOn: {
      click: this.nativeClickHandler
    },
    
    class: { // class is a special module, same API as `v-bind:class`
      foo: true,
      bar: false
    },
    
    style: { // style is also same as `v-bind:style`
      color: 'red',
      fontSize: '14px'
    },
    // other special top-level properties
    key: 'key',
    ref: 'ref',
    // assign the `ref` is used on elements/components with v-for
    refInFor: true,
    slot: 'slot'
  })
}
复制代码

table组件input值的绑定和获取: 1、render函数中不能直接使用v-model; 2、解决办法:

render: (h, {row}) => {
    return h('Input', {
      props: {
        clearable: true,
        placeholder: '标签编号',
        value: row.tagCode,
      },
      on: {
        input: (val) => {
          row.tagCode = val;
        }
      }
    });
  }
复制代码
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值