Vue-запрос на изменение маршрутизатора динамически в навигационном устройстве

#javascript #vue.js #vuejs2 #vue-component #vue-router

#javascript #vue.js #vuejs2 #vue-компонент #vue-маршрутизатор

Вопрос:

Есть один проект, над которым я работаю, и я застрял. Я хочу, чтобы при нажатии кнопки «Следующий шаг» маршрут менялся http://icontent.me/app/employer/make-order?step=1 и так далее.

Я использую Vue.js и vue-маршрутизатор.

Как мне это сделать? Я включил router.js и скриншот, если необходимо.

router.js

 import Vue from 'vue';
import VueRouter from 'vue-router';

// Import Routes //
import Welcome from '../components/Welcome.vue';
import Home from '../components/Home.vue';
import Admin from '../components/Admin.vue';

import HomePageContent from '../components/SectionHome/HomePageContent.vue';
import MakeOrder from '../components/Employer/MakeOrder.vue';

Vue.use(VueRouter);

export const router =new VueRouter({
   mode:'history',
   routes:[
     {
       path: '/',
       component:Welcome
     },
     {
       path: '/app/employer',
       component:Home,
       children:[
         {
           path:'',
           component:HomePageContent
         },
        {   
          path:'make-order',
          name:'make-order',
          component:MakeOrder, 
        },
       ]
     },
     {
       path:'/app/admin',
       component:Admin,
       children:[]
     },
   ]
});
  

следующий обработчик

 methods: {
    next () {
        if (this.current == 4) {
            //call finishing method here//
            this.current = 0;
        } else {
            this.current  = 1;
            //navigate route with the current step//
        }
    }
  

Комментарии:

1. где обработчик события click?

2. я включил обработчик click next, прокрутите вверх, чтобы увидеть

Ответ №1:

this.$router.push({ путь:this.$route.путь, запрос: { шаг: this.current } })