鍍金池/ 問答/網(wǎng)絡(luò)安全  HTML/ iview table中render使用匿名函數(shù)怎樣才能調(diào)用methods中的方

iview table中render使用匿名函數(shù)怎樣才能調(diào)用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);

}
}

回答
編輯回答
初心

1:click 用箭頭函數(shù).
2:在return上 render下 let self = this ;這樣接收一下this,就可以用了

2018年3月31日 22:13