vue-router

Contributor:游客21807577 Type:代码 Date time:2017-08-02 19:19:50 Favorite:21 Score:0
返回上页 Report
请选择举报理由:




Collection Modify the typo
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
//在路由中引入组件
import home from '@/components/home'
import document from '@/components/document'
import about from '@/components/about'
import user from '@/components/user'
import noFound from '@/components/404'
import study from '@/views/study'
import work from '@/views/work'
import hobby from '@/views/hobby'
import sliders from '@/views/slider'
let router = new VueRouter({
mode: 'history',
linkActiveClass: 'is-active',
scrollBehavior(to,from,savePosition){
/*if(savePosition){
return savePosition;
}else{
return {x:0,y:0}
}*/
if( to.hash){
return {
selector: to.hash
}
}
},
routes: [
{
path: '/',
component: home
},
{
path: '/user/:tip?/:userId?', // /user/vip/1 /user/common/2 /user
component: user
},
{
path: '/home',
name: 'Home',
component: home,
alias: '/index'
},
{
path: '/about',
component: about,
children: [
{
path: '',
name: 'About',
component: study
},
{
path: '/work',
name: 'Work',
component: work
},
{
path: '/hobby',
name: 'Hobby',
component: hobby
}
]
},
{
path: '/document',
name: 'Dcoument',
components: {
default: document,
slider: sliders
}
},
{
path: '*',
redirect: (to) => {
if( to.path === '/123' ) {
return '/home'
}else if(to.path === '/456'){
return {path: '/document'}
}else{
return {name: 'About'}
}
console.log(to)
//return '/home'
}
}
]
})
export default router;
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
Hot degree:
Difficulty:
quality:
Description: the system according to the heat, the difficulty, the quality of automatic certification, the certification of the article will be involved in typing!

This paper typing ranking TOP20

登录后可见

用户更多文章推荐