mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
add name on router for pages component
This commit is contained in:
parent
ddbffcc8af
commit
4c33c3c7f6
@ -146,8 +146,9 @@ function * generateRoutesAndFiles () {
|
|||||||
let routes = []
|
let routes = []
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
let path = file.replace(/^pages/, '').replace(/index\.vue$/, '/').replace(/\.vue$/, '').replace(/\/{2,}/g, '/')
|
let path = file.replace(/^pages/, '').replace(/index\.vue$/, '/').replace(/\.vue$/, '').replace(/\/{2,}/g, '/')
|
||||||
|
let name = file.replace(/^pages/, '').replace(/\.vue$/, '').replace(/\/{2,}/g, '/').split('/').slice(1).join('-')
|
||||||
if (basename(path)[0] === '_') return
|
if (basename(path)[0] === '_') return
|
||||||
routes.push({ path: path, component: r(this.dir, file) })
|
routes.push({ path: path, component: r(this.dir, file), name: name })
|
||||||
})
|
})
|
||||||
// Concat pages routes and custom routes in this.routes
|
// Concat pages routes and custom routes in this.routes
|
||||||
this.routes = routes.concat(this.options.router.routes)
|
this.routes = routes.concat(this.options.router.routes)
|
||||||
|
Loading…
Reference in New Issue
Block a user