实现:
data(){
return{
response:['fun1', 'fun2']
}
}
method:{
fun1(){
console.log('this is fun1')
}
fun2(){
console.log('this is fun2')
}
indirectCall(method){
this[method]()
}
/*
indirectCall(event, method){
// do something by event
this[method]()
}
*/
}
<!-- 为两个按钮分别绑定不同的响应方法 -->
<div v-for="(intem, index) in response" :key="index">
<button @click="indirectCall(item)">
<!-- 传递事件本身 -->
<!-- <button @click="indirectCall($event, item)"> -->
</button>
</div>