router-view在el-menu中会重新跳转新页面不在el-main中显示

<template>
  <div>
    <el-container>
      <el-header class="el-header"
                 style="background-color: black">
        header
      </el-header>
      <el-container>
        <el-aside width="200px">
          <!--引入自定义左侧菜单栏-->
          <el-row>
            <el-col>
              <el-menu class="el-menu-vertical-demo"
                       background-color="#E9EEF3"
                       text-color="black"
                       :router="true"
                       :default-active="this.$route.path">
                <el-menu-item index="/userInfo">测试1</el-menu-item>
                <el-menu-item index="/hello">测试2</el-menu-item>
                <el-menu-item index="/ceshi3">测试3</el-menu-item>
                <el-menu-item index="/ceshi4">测试4</el-menu-item>
              </el-menu>
            </el-col>
          </el-row>
        </el-aside>
        <el-main>
          <!--引入跳转路由-->
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data () {
    return {
      userinfo: {}
    }
  },
}
</script>
<style>
</style>

菜单栏如上,显示的页面如图

然后点击路由跳转时,页面会重新跳转到新的页面
为什么访问的页面不是显示在el-main框中呢

最佳答案

路由文件怎么写的,没用子路由吧

1年前 评论
mumu890420 (楼主) 1年前
讨论数量: 2

路由文件怎么写的,没用子路由吧

1年前 评论
mumu890420 (楼主) 1年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!