-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[vue] vue-router怎么重定向页面? #419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
vue
vue
Comments
路由中配置 |
也可以使用路由的别名来完成重定向 |
方法一:在routes:[{ |
以一个实例来说,最直观: export default {
path: '',
name: '',
meta: { //元信息(非必填)
icon: '', //路由图标
title: '', //路由名称
light: '', //高亮显示那个路由name
show: true, //是否显示
},
redirect: {
name: '', //重定向,指向哪个路由的name
},
component: '', //当前路由时要显示的组件
children: [], //嵌套子路由
} |
<div id="first">
<router-link to="/a">老八一号</router-link>
<router-view></router-view>
</div>
<script>
let a={
template:`<h1>奥里给 干了 兄弟们</h1>`
};
let b={
template:`<h2>虽然不是同一个时间,但是是同一个撤所儿</h2>`
};
let routeObj=new VueRouter({
routes:[
{path:'/a',redirect:'/b'},
{path:'/b',component:b}
]
});
let vm=new Vue({
el:"#first",
data:{},
router:routeObj
})
</script>
|
<div id="first">
<router-link to="/xiangcunlove">乡村爱情</router-link>
<router-link to="/horsebighandsome">马大帅</router-link>
<router-view></router-view>
</div>
<script>
let horse={
template:`<div>水库浪子--范德彪</div>`
};
let horse2={
template:`<div>我谢广坤这辈子没说过谢字</div>`
};
let routerObj=new VueRouter({
routes:[
{path:'/xiangcunlove', redirect:{name:'dashuai'}},
{path:'/horsebighandsome',component:horse},
{path:'/horsebighandsome2',component:horse2,name:'dashuai'},
]
});
let vm=new Vue({
el:'#first',
router:routerObj
})
</script> |
routes:[{ path: "/", redirect: '/xxxxxx' }] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[vue] vue-router怎么重定向页面?
The text was updated successfully, but these errors were encountered: