轮循
// 轮询功能
getCircle() {
const { fetch } = this
this.timer = window.setInterval(() => {
setTimeout(() => {
fetch()
}, 0)
}, 2000)
}
销毁和开始
beforeRouteEnter(to, from, next) {
next(v => v.getCircle())
},
beforeRouteLeave(to, from, next) {
window.clearInterval(this.timer)
next()
},
文件数据上传
async handleSave(){
const formData = new FormData()
formData.set('file', this.file)
const res = await updateImg(formData)
if(res.status === 200){
console.log(res);
console.log('保存')
}