Как получить значение параметра в vue.js 2 router?

Я пытаюсь получить значение параметра Myparam $route.params.Myparam но роутер не виден Uncaught ReferenceError: $route is not defined
ссылка выглядит так site/bla-bla-bla/:Myparam тоесть site/bla-bla-bla/555 как мне в Javascript вытащить 555?

//Тут глобальные методы и затем Глобальные данные
var GM = {
    A_tyt_ya_hochy_yznat_znachenie_parametra_routera: function () {

    }//........
var GD = {......}

        var routes = [
            { path: '/', component: IndexPage, name: "IndexPage" },
            { path: '/patients', component: PatientsPage, name: "PatientsPage" },
            {
                path: '/notfalls', component: NotfallePage, name: "NotfallePage",
                children: [
                    {
                        path: ':NotfallId', 
                        component: NotfallPage,
                        name: 'NotfallPage',
                        onEnter: function () {
                            //console.log($router.params.userId);
                        },
                        created: function () {

                        } 
                    }
                ]
            },
            { path: '/notfall/new', component: NotfallNewPage, name: "NotfallNewPage"}
        ];
        var router = new VueRouter({ mode: 'history', routes });

        var app = new Vue({
            router,
            el: '#app',
            data: function () {
                return GD;
            },
            events: {},
            methods: {
                GM: function () {
                    return GlobalMethods;
                },
                ServerConnect: function () {
                    //GlobalData.connection = ReconnectToServer(GlobalData);
                } 
            },
            created: function () {

            },
            /*watch: {
                '$route'(to, from) {
                    //console.log('Router from-' + to.path + '  to- ' + from.path);
                    //console.log($rout.params);
                }
            }*/
        });
  • Вопрос задан
  • 396 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы