const router = new VueRouter({
routes: [
{ path: '/', component: { template: '<div>Home</div>' } },
{ path: '/foo', component: { template: '<div>Foo</div>' } },
{ path: '/boo', component: { template: '<div>Boo</div>' } },
],
});
new Vue({
router,
el: '#app',
data: () => ({
routeIndex: 0,
}),
created() {
setInterval(() => {
const { routes } = this.$router.options;
this.routeIndex = (this.routeIndex + 1) % routes.length;
this.$router.push(routes[this.routeIndex]);
}, 1000);
},
});
<div id="app">
<router-view></router-view>
</div>