VUE多层路由嵌套实现代码
发布时间:2020-12-17 02:58:12 所属栏目:百科 来源:网络整理
导读:先看看效果图: 例如:在做系统时,主页面有两个功能【home】and【news】,在【home】下又分为登录和注册。 首先需要将各种模板进行抽离。定义模板 news this is login template id="zhuce" //home模板下的注册 this is zhuce JS下配置路由 var rout=[ {path:'
先看看效果图: 例如:在做系统时,主页面有两个功能【home】and【news】,在【home】下又分为登录和注册。 首先需要将各种模板进行抽离。定义模板 <template id="zhuce"> //home模板下的注册 this is zhuce
JS下配置路由 var rout=[
{path:'/',redirect:'/home'},//重定向为home ,当html后面哈希值为空时,默认显示home { path:'/home',component:home,//模板注册 redirect:'/home/login',//子视口的重定向 默认登录 children:[ {path:'/home/login',component:login},//配置子模板 {path:'/home/zhuce',component:zhuce} ]},{path:'/news',component:news} ]; var router=new VueRouter({ //实例化一个vuerouter const app = new Vue({ 当Vue实例没有el属性时,则该实例尚没有挂载到某个dom中; 假如需要延迟挂载,可以在之后手动调用vm.$mount()方法来挂载。 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |