Vue rookie, when learning to use vue-router, in redirection, I found that it could not be realized. After referring to the example on the official website, I couldn"t find out what went wrong. I would like to ask the elders for advice. Thank you very much ~
.the following is the code
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: "-sharpapp",
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>