在Vue中动态挂载组件
首先需要安装 cnpm install vue-router --save
在main.js中引入VueRouter 并使用
定义一个路由
创建router实例
通过router配置参数注入路由
关于嵌套路由
要在嵌套的出口中渲染组件,在需要VueRouter
的参数中使用children
配置:
college和major属于home的子路由
路由匹配的组件会显示在这里
原文:https://www.cnblogs.com/zlwei23/p/10981077.html