在Vue中建立子路由的方法:1.新建html项目,引入vue和vue-router;2.使用Vue.use方法注册路由;3.定义路由;4.在children属性中添加子路由;具体步骤如下:首先,在新建一个html项目,并在项目中引入vue和
在Vue中建立子路由的方法:1.新建html项目,引入vue和vue-router;2.使用Vue.use方法注册路由;3.定义路由;4.在children属性中添加子路由;
具体步骤如下:
首先,在新建一个html项目,并在项目中引入vue和vue-router;
import Vue from 'vue'
import Router from 'vue-router'
vue和vue-router引入好后,在项目中使用Vue.use方法注册路由;
Vue.use(Router)
路由注册好后,在页面中定义一个路由;
export default new Router({
routes: [
{
path : ‘/’,
name : ‘Home’,
component : HelloWorld,
children:[
{path:'/', component: Child},
]
},
]
})
最后,路由定义好后,在children属性中添加上子路由路径即可;
export default new Router({
routes: [
{
path : ‘/’,
name : ‘Home’,
component : HelloWorld,
children:[
{path:'/', component: Child},
{path:'/Mes/Child', component: Child},
]
},
]
})
--结束END--
本文标题: vue如何建立子路由
本文链接: https://www.lsjlt.com/news/110604.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
2024-05-16
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0