iview的table表格加按钮不生效?

官方文档是这样写的 结果不生效

 {
    
    
   title: '操作',
   key: 'action',
     width: 150,
     align: 'center',
     render (row, column, index) {
    
    
         return `<i-button type="primary" size="small" @click="show(${
      
      index})">查看</i-button> <i-button type="error" size="small" @click="remove(${
      
      index})">删除</i-button>`;
     }
}

换种写法 使用 h函数(创建虚拟dom的)

{
    
    
    title: 'Action',
     key: 'action',
     width: 150,
     align: 'center',
     render: (h, params) => {
    
    
         return h('div', [
             h('Button', {
    
    
                 props: {
    
    
                     type: 'primary',
                     size: 'small'
                 },
                 style: {
    
    
                     marginRight: '5px'
                 },
                 on: {
    
    
                     click: () => {
    
    
                         console.log('我触发了')
                     }
                 }
             }, '查看物流')
         ]);
     }
}

ok 搞定

猜你喜欢

转载自blog.csdn.net/weixin_42821697/article/details/120329378#comments_21488995
今日推荐