Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/chapter2_sec2 #146

Merged
merged 5 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/chapter2/section2/0_router-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Vue Router を読み込むように`src/main.ts`を以下のように変更し

<<<@/chapter2/section2/src/1/routes.ts{typescript:line-numbers}

この後、皆さんにはいくつかのページとその`path`の対応を追加してもらうわけですが、どの`path`にもマッチしなかった場合、任意の`path`にマッチする`/:path(.*)`がマッチし、NotFound ページが表示されます。
この後、皆さんにはいくつかのページとその`path`の対応を追加してもらうわけですが、どの`path`にもマッチしなかった場合、任意の`path`にマッチする`/:path(.*)*`がマッチし、NotFound ページが表示されます。

`src/pages/NotFound.vue`を以下の内容で作成してください。

Expand Down
4 changes: 4 additions & 0 deletions docs/chapter2/section2/2_fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

<<<@/chapter2/section2/src/2/router.ts{typescript:line-numbers}

また併せて、`src/App.vue`にリンクを追加します。

<<<@/chapter2/section2/src/2/App.vue{vue:line-numbers}

`http://localhost:5173/ping`にアクセスすると以下のような画面が表示されれば OK です。

![](images/2/ping.png)
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/1/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import NotFound from './pages/NotFound.vue'

const routes = [
{ path: '/', name: 'home', component: HomePage },
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/1/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const routes = [
{ path: '/', name: 'home', component: HomePage },
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/1/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({
'/api': {
target: 'http://localhost:8080',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/')
rewrite: (path: string) => path.replace(/^\/api/, '/')
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/2/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PingPage from './pages/PingPage.vue' //[!code ++]
const routes = [
{ path: '/', name: 'home', component: HomePage },
{ path: '/ping', name: 'ping', component: PingPage }, //[!code ++]
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/2/router_2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const routes = [
{ path: '/', name: 'home', component: HomePage },
{ path: '/ping', name: 'ping', component: PingPage },
{ path: '/login', name: 'login', component: LoginPage }, //[!code ++]
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/2/router_3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const routes = [
{ path: '/ping', name: 'ping', component: PingPage },
{ path: '/login', name: 'login', component: LoginPage },
{ path: '/city/:cityName', name: 'city', component: CityPage, props: true }, //[!code ++]
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion docs/chapter2/section2/src/2/router_4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const routes = [
{ path: '/ping', name: 'ping', component: PingPage },
{ path: '/login', name: 'login', component: LoginPage },
{ path: '/city/:cityName', name: 'city', component: CityPage, props: true },
{ path: '/:path(.*)', component: NotFound }
{ path: '/:path(.*)*', component: NotFound }
]

const router = createRouter({
Expand Down
4 changes: 2 additions & 2 deletions docs/chapter2/section2/src/2/router_5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import CityPage from './pages/CityPage.vue'

const routes = [
{ path: '/', name: 'home', component: HomePage, meta: { isPublic: true } },
{ path: '/ping', name: 'ping', component: PingPage },
{ path: '/ping', name: 'ping', component: PingPage, meta: { isPublic: true } },
{
path: '/login',
name: 'login',
component: LoginPage,
meta: { isPublic: true }
},
{ path: '/city/:cityName', name: 'city', component: CityPage, props: true },
{ path: '/:path(.*)', component: NotFound, meta: { isPublic: true } }
{ path: '/:path(.*)*', component: NotFound, meta: { isPublic: true } }
]

const router = createRouter({
Expand Down
Loading