这里的activeIndex要设置,return要有返回的activeIndex的内容
<template> <div class="common-layout"> <el-container> <el-header> <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" > <el-menu-item index="1">Processing Center</el-menu-item> <el-sub-menu index="2"> <template #title>Workspace</template> <el-menu-item index="2-1">item one</el-menu-item> <el-menu-item index="2-2">item two</el-menu-item> <el-menu-item index="2-3">item three</el-menu-item> <el-sub-menu index="2-4"> <template #title>item four</template> <el-menu-item index="2-4-1">item one</el-menu-item> <el-menu-item index="2-4-2">item two</el-menu-item> <el-menu-item index="2-4-3">item three</el-menu-item> </el-sub-menu> </el-sub-menu> <el-menu-item index="3" disabled>Info</el-menu-item> <el-menu-item index="4">Orders</el-menu-item> </el-menu> </el-header> <el-main>Main</el-main> </el-container> </div> </template> <script> export default { data(){ return{ activeIndex: '1' } } }; </script> <style scoped lang="less"> .el-header { background-color: #b3c0d1; color: #333; text-align: center; line-height: 60px; } .el-main { background-color: #e9eef3; color: #333; text-align: center; line-height: 160px; } </style>
el-main中填写router-view
children的资料
要与组件相搭
element-ui默认跳转
这时候我们在用的时候,没有看到home组件
添加路由必须在menu中添加:router="true"
<el-input @keydown.enter="mySearch()" placeholder="请输入您想看的视频">