2.0.11
Chrome 63.0.3239.132
2.5.13
https://jsfiddle.net/Lfaosg6h/
在upload组件的before upload钩子中修改action上传地址,当前文件上传地址没有变化,再一次上传action才变化


在before upload钩子中修改action,并让当前文件按新地址上传
当前文件依旧按旧地址上传,再次上传文件,action才是修改后的新地址
Translation of this issue:
2.0.11
Chrome 63.0.3239.132
2.5.13
https://jsfiddle.net/Lfaosg6h/
Modify the action upload address in the upload component's before upload hook. The current file upload address does not change, and the action is uploaded again.
Modify the action in the before upload hook and allow the current file to be uploaded by the new address
The current file is still uploaded by the old address, and the file is uploaded again. Action is the new address after the modification.
你好,你可以这样解决:
https://jsfiddle.net/Lfaosg6h/3/
组件设计时,并不考虑改变原始值。 并且Vue的一些机制导致了这个问题,具体可以看这个例子:
https://jsfiddle.net/leopoldthecuber/Lfaosg6h/2/
@Hi-Linlin 感谢你的解决方案
链接失效了,遇到这个问题了,能麻烦再放下链接么,谢谢
@isuye
<el-upload class="upload-demo" :action="url" :before-upload="test">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
var Main = {
data () {
return {
url: '123'
};
},
methods: {
test (file) {
return new Promise((resolve, reject) => {
this.$nextTick(() => {
this.url = '321'
resolve()
})
})
}
}
}
@286506460
谢谢
链接打不开???
@DaiChongyu this.Api = 321
data: {
url: ''
},
mounted: function() {
this.changeUrl();
},
methods: {
changeUrl: function () {
this.$nextTick(() => {
this.url = '321';
})
},
}
放到 mounted 里可以避免第一次不改变, 我这是引入模式 changeUrl函数放到其他函数里依然会导致第二次才能改变成功
Most helpful comment
你好,你可以这样解决:
https://jsfiddle.net/Lfaosg6h/3/
组件设计时,并不考虑改变原始值。 并且Vue的一些机制导致了这个问题,具体可以看这个例子:
https://jsfiddle.net/leopoldthecuber/Lfaosg6h/2/