编程式导航
与router-link导航相比,router-link类似于a标签,编程式导航相当于ajax,导航用页面跳转
Home.vue
<.../components/Goods.vue';
// 2.配置路由
const routes=[
{path:'/home',component:Home},
{path:'/news...',component:News},
{path:'/vcontent/:aid',component:vContent}, //动态路由
{path:'*',redirect...:'/home'}, //默认路由跳转到首页
{path:'/goods',component:Good},
]
//注意,这里是routes,而不是routers
// 3.实例化VueRouter