перекрытие при определении маршрутов в маршрутизаторе nuxt js - PullRequest
0 голосов
/ 11 марта 2020

Я пытаюсь создать блог с nuxt js. Но у меня проблема с маршрутизацией.

Я определяю этот маршрут localhost/@:username/{slug}, чтобы показать сообщение. также я хочу иметь эти маршруты:

localhost/@:username/edit, localhost/@:username/posts, localhost/@:username/followers, ...

Но это создает помехи, и все они направляются, чтобы показать страницу поста.

мой роутер:

import Vue from 'vue';
import Router from 'vue-router';
import {scrollBehavior} from '~/utils';

Vue.use(Router);

const page = path => () => import(`~/pages/${path}`).then(m => m.default || m);

const routes = [
    {
    path: '/@:username',
    component: page('user/profile/index.vue'),
    children: [
        {path: '', name: 'profile', component: page('user/profile/profile.vue'),},
        {path: '/edit', name: 'profile-edit', component: page('user/profile/edit.vue')},
        {path: '/following', name: 'profile-following', component: page('user/profile/following.vue')},
        {path: '/followers', name: 'profile-followers', component: page('user/profile/followers.vue')},
     ]
    },
    {path: '/@:username/:slug', name: 'post', component: page('site/posts/show-post.vue')},
];

export function createRouter() {
    return new Router({
        routes,
        scrollBehavior,
        mode: 'history'
    });
}
...