R
R
Roman Rakzin2017-02-28 19:43:26
Vue.js
Roman Rakzin, 2017-02-28 19:43:26

How to get parameter value in vue.js 2 router?

I'm trying to get the value of Myparam $route.params.Myparam but the router is not
visible Javascript pull 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);
                }
            }*/
        });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question