iview table中render使用匿名函数怎样才能调用methods中的方法

新手上路,请多包涵
                render: function(h,params) {                                      
                    return h('div', [

                        h('Button', {
                            props: {
                                type: 'primary',
                                size: 'small'
                            },
                            style: {
                                marginRight: '5px'
                            },
                            on: {
                                click: function() {                                    
                                    console.log(this);
                                    this.show(params.index) 
                                }
                            }
                        }, '编辑'),
                        
                    ]);
                }
                
            
methods: {
    show: function(index) {
   alert(index);

}
}

阅读 5k
2 个回答

1:click 用箭头函数.
2:在return上 render下 let self = this ;这样接收一下this,就可以用了

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