我正在使用Element UI的上传组件.遗憾的是,一旦上传文件就会触发POST请求.我的目标是将文件推送到一个空数组,该数组将在按钮后发布.
HTML
// Element UI documentation says http-request overrides xhr behavior
// so I can use my own file request. In this case, I wanted to use a method
// though I'm not quite sure about this part?
<el-upload
action="",
:http-request="addAttachment",
:on-remove="deleteAttachment",
:file-list="attachments">
<el-button size="mini" type="primary">Add file</el-button>
</el-upload>
// button that uploads the files here
Run Code Online (Sandbox Code Playgroud)
JS
data() {
attachments: []
},
methods: {
addAttachment ( file, fileList ) {
this.attachments.push( file );
},
deleteAttachment () {
// removes from …Run Code Online (Sandbox Code Playgroud)