vue在触发事件时附加自定义参数以ElementUI
的分页组件为例,
我们找个事件
比如
1 | <el-pagination |
1 | /** |
如上述代码,我们触发分页的事件后,changePage方法只能接受到一个index参数,如果我们修改成以下写法就会报错。
1 | :current-change='changePage(index, id)' |
解决方法
使用ES写法解决
1 | :current-change='(index) => {changePage(index, id)}' |
1 | changePage(index, id){ |