iview -- 列表渲染

渲染函数

render: (h) => {
  return h('标签', {
    属性
  }, '填充文本')
}
render: (h) => {
  return h('div', [
    h('标签', {
     //  属性
      style: { color: '#432FDE' },
      attrs: { class: 'operation' },
    }, '填充文本')
  ])
}

列表渲染

export default {
  data () {
    return {
      column: [
        {
          title: '序号',
          align: 'center',
          width: 66,
          render: (h, params) => {
            return h('small', {}, (this.condition.pageNum - 1) * this.condition.pageSize + params.index + 1)
          }
        },
        // 最常见的匹配
        {
          title: '角色编码',
          key: 'code',
          tooltip: true,
          width: 200,
          align: 'center'
        },
        // 字符匹配
        {
          title: '状态',
          width: 190,
          align: 'center',
          render: (h, params) => h('span', this.dic.state.find(({ code }) => (code === params.row.state)).name)
        },
        // 宽度自适应
        {
          title: ' '
        },
        // 自定义操作
        {
          title: '操作',
          width: 100,
          align: 'center',
          fixed: 'right',
          render: (h, params) => {
            return h('div', [
              h('span', {
                style: { color: '#432FDE' },
                attrs: { class: 'operation' },
                on: {
                  click: e => {
                    this.state(params)
                    e.stopPropagation()
                  }
                }
              }, '设置'),
              h('span', {
                style: { color: '#a08418' },
                attrs: { class: Object.keys(params.row.state)[0] === '1' ? 'operation' : 'unoperation' },
                on: {
                  click: e => {
                    this.setAble(params)
                    e.stopPropagation()
                  }
                }
              }, '禁用')
            ])
          })
        }
      ]
    }
  }
}

渲染函数实例

render: (h) => {
  return h('div', [
    h('Icon', {
      'class': 'spin-icon-load'
    }),
    h('div', {
      style: 'font-size:20px;'
      attrs: { class: Object.keys(params.row.state)[0] === '1' ? 'operation' : 'unoperation' },
      props: {
        type: 'ios-loading',
        size: 32
      },
      on: {
        click: e => {
          e.stopPropagation()
        }
      }
    }, '正在上传...')
  ])
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值