Vue小白,在学习使用vue-router,在重定向的时候发现无法实现,参考了官网的例子找不出哪里出错了,求各位前辈大神们指点,不胜感激~~以下是代码部分var Home = { template: '<h3>Home</h3>' }; var News = { template: '<h3>News</h3>' }; var Travel = { template:'<h3>Travel</h3>' } //生成路由实例 const router = new VueRouter({ // routes, routes : [ {path: '/home',component: Home}, {path: '/news',component: News}, {path:'/travel',component:Travel}, //重定向 {path:'/home',redirect:'/travel'} ] }) // 最后挂到vue上 new Vue({ el: '#app', router, })<div id="app"> <div> <router-link to='/home'>Home</router-link> <router-link to='/news'>News</router-link> <router-link to='/travel'>Travel</router-link> </div> <div> <router-view></router-view> </div> </div>
添加回答
举报
0/150
提交
取消