使用延时加同步方法解决
- beforeupload(file) {
- console.log(file)
- const that = this
- setTimeout(async() => {
- await that.$message({ type: 'success', message: file.name })
- // Message({
- // message: file.name,
- // type: 'error'
- // })
- })
- // 重点是 setTimeout async await
- // this.$message({ type: 'success', message: file.name })
- }
来源: http://www.jianshu.com/p/e73a6a6d81d0