您的位置:首页 > Web前端 > Vue.js

Vue router内调用组件(嵌套router)

2020-07-24 12:02 57 查看

本教程在上一篇Vue router使用方法的基础上进行

Vue router使用方法

1、在components文件夹中新建三个组件Text1、Text2、Text3

2、在router.js中引入组件

import Text1 from './components/Text1'
import Text2 from './components/Text2'
import Text3 from './components/Text3'

3、在routes内嵌套children

children: [{
path: '/',
redirect: 'text1'
},
{
path: 'text1',
component: Text1
},
{
path: 'text2',
component: Text2
},
{
path: 'text3',
component: Text3
},
]


4、打开浏览器即可显示

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: