单页面多路由区域操作
在一个页面中有两个及以上的区域,需要通过设置路由的index.js,来操作这些区域的内容
app.vue 中设置:
index.js中设置:
import vue from 'vue'
import router from 'vue-router'
import hello from '@/components/hello'
import first1 from '@/components/first1'
import first2 from '@/components/first2'
vue.use(router)
export default new router ({
routes : [
{
path : '/',
name : 'hello',
components : {
default : hello,
left : first1,
right : first2
}
}
]
})
下面的设置是当url为/#/first 时,交换两个组件显示的位置
export default new router ({
routes : [
{
path : '/',
name : 'hello',
components : {
default : hello,
left : first1,
right : first2
}
}, {
path : '/first',
name : 'first',
components : {
default : hello,
left : first2,
right : first1
}
}
]
})
以上就是 vue.js 单页面多路由区域操作,如有疑问请大家留言,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
希望与广大网友互动??
点此进行留言吧!