mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
fix(generator): handle when no routes.json
defined (#8166)
This commit is contained in:
parent
dfaa1960f7
commit
34f32113b4
@ -48,7 +48,7 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
async '$route.query.page' (page) {
|
async '$route.query.page' (page) {
|
||||||
this.$nuxt.$loading.start()
|
this.$nuxt.$loading.start()
|
||||||
const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`)
|
const data = await fetch(`https://reqres.in/api/users?page=${page}`).then(res => res.json())
|
||||||
this.users = data.data
|
this.users = data.data
|
||||||
this.transitionName = this.getTransitionName(page)
|
this.transitionName = this.getTransitionName(page)
|
||||||
this.page = +(page || 1)
|
this.page = +(page || 1)
|
||||||
|
@ -104,7 +104,13 @@ export default class Generator {
|
|||||||
if (this.options.router.mode === 'hash') {
|
if (this.options.router.mode === 'hash') {
|
||||||
routes = ['/']
|
routes = ['/']
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
routes = flatRoutes(this.getAppRoutes())
|
routes = flatRoutes(this.getAppRoutes())
|
||||||
|
} catch (err) {
|
||||||
|
// Case: where we use custom router.js
|
||||||
|
// https://github.com/nuxt-community/router-module/issues/83
|
||||||
|
routes = ['/']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
routes = routes.filter(route => this.shouldGenerateRoute(route))
|
routes = routes.filter(route => this.shouldGenerateRoute(route))
|
||||||
routes = this.decorateWithPayloads(routes, generateRoutes)
|
routes = this.decorateWithPayloads(routes, generateRoutes)
|
||||||
|
Loading…
Reference in New Issue
Block a user