iview table里面加图片

我想在iview table里面添加图片
我的代码(请忽略竖线)

clipboard.png

渲染之后只有img标签,没有src属性

clipboard.png

请问这里应该怎么做呀

阅读 13.7k
4 个回答

应该用attrs而不是 props.

{
  title: '头像', key: 'headimg',
  render: (h, params) => {
    console.log(params.row)
    return h('div', {
      attrs: {
        style: 'width: 40px;height: 40px;'
      },
    }, [
        h('img', {
          props: {
            type: 'primary',
            size: 'small'
          },
          attrs: {
            src: params.row.headimg, style: 'width: 40px;height: 40px;border-radius: 2px;'
          },
          style: {
          },
        }),
      ]);
  }
},

props 是组件属性, attr是html属性

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题