今天用iview的上传组件 Upload 的时候,需要在点击上传按钮时多接收几个参数,发现内置的方法
:before-upload=“handleBeforeUpload”
handleBeforeUpload (file) {
console.log(file)
}
这个内置方法不能自定义传参,需要进行特殊的写法,使用箭头函数,改成这样:
:before-upload="(file) => handleUpload(file, index)"
handleBeforeUpload (file, index) {
console.log(file)
}
参考官方说明:https://dev.iviewui.com/examples/1085740304402878464