This repository was archived by the owner on Jul 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +35
-19
lines changed Expand file tree Collapse file tree 6 files changed +35
-19
lines changed Original file line number Diff line number Diff line change 11// https://qiita.com/iwata@github /items/5bc61ea9ca1c692d0370
22import { Configuration } from 'webpack'
33import { Context } from '@nuxt/vue-app'
4+ import routers from './src/routers/'
45
56const pkg = require ( './package' )
67
@@ -121,18 +122,11 @@ module.exports = {
121122 middleware : 'check-auth' ,
122123
123124 extendRoutes ( routes : any , resolve : any ) {
124- // https://ja.nuxtjs.org/api/configuration-router/#extendroutes
125- routes . push ( {
126- name : 'custom-path' ,
127- path : '/example/(c|d)-:a/(e|f)-:b/*' ,
128- component : resolve ( __dirname , 'src/routed-pages/custom-path.vue' )
129- } )
130-
131- routes . push ( {
132- name : 'include' ,
133- path : '/include' ,
134- component : resolve ( __dirname , 'src/include/include.vue' )
135- } )
125+ if ( routers && routers . length > 0 ) {
126+ for ( let i = 0 , len = routers . length ; i < len ; i ++ ) {
127+ routers [ i ] ( routes , resolve )
128+ }
129+ }
136130 }
137131 } ,
138132 styleResources : {
Original file line number Diff line number Diff line change 11# ROUTED_PAGES
22
3- This directory contains your Application Views and Routes.
4- The framework reads all the ` *.vue ` files inside this directory and creates the router of your application.
3+ nuxt.config.ts の ` router.extendRoutes ` でカスタムルーティングしたいが、 pages にファイルを配置すると ` .vue ` ファイルの名前でアクセスできてしまう。
54
6- More information about the usage of this directory in [ the documentation ] ( https://nuxtjs.org/guide/routing ) .
5+ それを防ぐのが、 ` routed-pages ` と ` routers ` です。
76
8- router の extendRoutes でルーティングをカスタムすると ` *.vue ` ファイルは直接見られたくないけど、
9- ルーティングのときには表示したいページがある。
10-
11- それを routed-pages に置くことで、 pages のようにファイルを置くと見られるということがなくなる。
7+ routers でカスタムルーティングを定義し、 routed-pages のファイルを指定するのが pages を使わない場合のルールです。
Original file line number Diff line number Diff line change 1+ # ROUTERS
2+
3+ nuxt.config.ts の ` router.extendRoutes ` でカスタムルーティングしたいが、 pages にファイルを配置すると ` .vue ` ファイルの名前でアクセスできてしまう。
4+
5+ それを防ぐのが、 ` routed-pages ` と ` routers ` です。
6+
7+ routers でカスタムルーティングを定義し、 routed-pages のファイルを指定するのが pages を使わない場合のルールです。
Original file line number Diff line number Diff line change 1+ export default function ( routes : any , resolve : any ) : void {
2+ // https://ja.nuxtjs.org/api/configuration-router/#extendroutes
3+ routes . push ( {
4+ name : 'custom-path' ,
5+ path : '/example/(c|d)-:a/(e|f)-:b/*' ,
6+ component : resolve ( __dirname , '../../src/routed-pages/custom-path.vue' )
7+ } )
8+ }
Original file line number Diff line number Diff line change 1+ export default function ( routes : any , resolve : any ) : void {
2+ routes . push ( {
3+ name : 'include' ,
4+ path : '/include' ,
5+ component : resolve ( __dirname , '../../src/include/include.vue' )
6+ } )
7+ }
Original file line number Diff line number Diff line change 1+ import customPath from './custom-path'
2+ import include from './include'
3+
4+ export default [ customPath , include ]
You can’t perform that action at this time.
0 commit comments