const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }
const router = new VueRouter({
routes:[
{path: '/', component: Foo},
{path: '/bar', component: Bar},
{path: '/foo/:id', redirect: '/'}
]
})
let vm = new Vue({
el: '#app',
data: {
},
methods: {
},
components: {
},
router
})
动态路由
规则如果有接收参数
{ path: '/foo/:id', component: Foo }
编程式,也要带参才正常显示
this.$router.push('/foo/1')
动态路由获取参数的方法
$route.params.id
人生很漫长,或许我只是你人生中微不足道的一小段,只是你人生中的惊鸿一瞥。
浙公网安备 33010602011771号