https://github.com/ElemeFE/element http://element.eleme.io/#/en-US/component/upload
<el-upload
class="avatar-uploader"
action="/upload"
:show-file-list="false"
:on-error="handleUrlError"
:on-success="handleUrlSuccess">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
功能:
handleUrlSuccess(response, file, fileList) {
}
如果添加额外的参数:
<el-upload
class="avatar-uploader"
action="/upload"
:show-file-list="false"
:on-error="handleUrlError"
:on-success="handleUrlSuccess(response, file, fileList, 233)">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
功能:
handleUrlSuccess(response, file, fileList, param) {
}
属性或方法“响应”未在实例上定义,但在渲染期间被引用。
答案 0 :(得分:0)
方法的参数来自组件的发出的成功事件。例如,它会有类似的
this.$emit('on-success', response, file, fileList)
在内部,Vue会做类似的事情(这非常简化)...
let boundEventHandler = parseEventHandlerExpression(eventName)
boundEventFunction.apply(vmInstance, arguments)
您可以在消费者中执行的操作是捕获所有这些参数,然后附加自己的参数
:on-success="handleUrlSuccess(...arguments, 233)"