mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-08 01:42:38 +00:00
refactor: minior improvements
- ensure message is a string - use location.reload to support hash # and also explictly bypass cache - added minor comments
This commit is contained in:
parent
c4cfd08185
commit
daf90215b5
@ -140,11 +140,16 @@ async function loadAsyncComponents (to, from, next) {
|
||||
next()
|
||||
} catch (err) {
|
||||
err = err || {}
|
||||
if (/^Loading chunk (\d)+ failed\./.test(err.message)) {
|
||||
window.location.replace(location.href)
|
||||
const statusCode = err.statusCode || err.status || (err.response && err.response.status) || 500
|
||||
const message = err.message || ''
|
||||
|
||||
// Handle chunk loading errors
|
||||
// This may be due to a new deployment or a network problem
|
||||
if (/^Loading chunk (\d)+ failed\./.test(message)) {
|
||||
window.location.reload(true /* skip cache */)
|
||||
}
|
||||
const statusCode = (err.statusCode || err.status || (err.response && err.response.status) || 500)
|
||||
this.error({ statusCode, message: err.message })
|
||||
|
||||
this.error({ statusCode, message })
|
||||
this.$nuxt.$emit('routeChanged', to, from, err)
|
||||
next(false)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user