add catch ajax error
This commit is contained in:
parent
e15c53a6b8
commit
ec58149aad
2 changed files with 5 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ export default function (url, options = {}) {
|
|||
xhr.send()
|
||||
|
||||
return {
|
||||
then: cb => xhr.addEventListener('load', cb)
|
||||
then: cb => xhr.addEventListener('load', cb),
|
||||
catch: cb => xhr.addEventListener('error', cb)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ class Docsify {
|
|||
}
|
||||
|
||||
load () {
|
||||
ajax(`${this.loc}.md`).then(res => {
|
||||
ajax(`${this.loc}.md`)
|
||||
.then(res => {
|
||||
const target = res.target
|
||||
if (target.status >= 400) {
|
||||
this.render('not found')
|
||||
|
|
@ -52,6 +53,7 @@ class Docsify {
|
|||
}
|
||||
}
|
||||
})
|
||||
.catch(_ => this.render('not found'))
|
||||
}
|
||||
|
||||
render (content) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue