Riunshow / NoteBook

人生不如意事十之九八,可与人言者并无二三
3 stars 0 forks source link

axios中断请求 #15

Open Riunshow opened 5 years ago

Riunshow commented 5 years ago
import axios from 'axios'
let CancelToken = axios.CancelToken
let cancel

axios.get('/user/12345', {
    cancelToken: new CancelToken(function executor(c){
        cancel = c
    })
})

//取消请求
cancel()

export { cancel }