This repository was archived by the owner on Jul 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +55
-1
lines changed Expand file tree Collapse file tree 4 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ section
5151 nuxt-link( to ='/example/now-utcoffset' ) now-utcoffset
5252 p
5353 nuxt-link( to ='/example/vue-carousel' ) vue-carousel
54+ p
55+ nuxt-link( to ='/example/routing-validate/true' ) routing-validate - validate is true
56+ p
57+ nuxt-link( to ='/example/routing-validate/false' ) routing-validate - validate is not true
5458</template >
5559
5660<script lang="ts">
Original file line number Diff line number Diff line change 1+ <template lang="pug">
2+ section.container
3+ h1.title
4+ | routing-validate
5+ div
6+ p path: {{ path }}
7+ p params: {{ params }}
8+ p query: {{ query }}
9+ </template >
10+
11+ <script lang="ts">
12+ import { Component , Vue } from ' nuxt-property-decorator'
13+
14+ @Component
15+ export default class extends Vue {
16+ public asyncData({ route }: any ) {
17+ return {
18+ path: route .path ,
19+ params: route .params ,
20+ query: route .query
21+ }
22+ }
23+
24+ public validate({ params , query , store }) {
25+ if (params .condition === ' true' ) {
26+ return true // params バリデーションを通過したとき
27+ }
28+
29+ return false // Nuxt.js がルートをレンダリングするのを中止して、エラーページを表示させる
30+ }
31+
32+ public head() {
33+ return {
34+ title: ' routing-validate'
35+ }
36+ }
37+ }
38+ </script >
Original file line number Diff line number Diff line change 11import customPath from './custom-path'
2+ import routingValidate from './routing-validate'
23import include from './include'
34
4- export default [ customPath , include ]
5+ export default [ customPath , routingValidate , include ]
Original file line number Diff line number Diff line change 1+ import INuxtRoute from '../interfaces/INuxtRoute'
2+
3+ export default function (
4+ resolve : ( dirname : string , routeDir : string ) => string
5+ ) : INuxtRoute {
6+ return {
7+ name : 'routing-validate' ,
8+ path : '/example/routing-validate/:condition/' ,
9+ component : resolve ( __dirname , '../routed-pages/routing-validate.vue' )
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments