vue路由改变,页面不变?
**图片有点模糊,将就一下,高质量的图片试了很多次传不上去。
大致就是从login的页面跳转到home界面后,router-view里面的内容变成了login的内容,about的内容倒是没有变,什么原因?怎么解决?**
//路由配置const routes: Array<RouteConfig> = [
{
path: '/login',
name: 'Login',
component: () => import('../views/Account/Login.vue')
},
{
path: '/',
name: 'Main',
component: Main,
redirect: 'home',
children: [
{
path: '/home',
name: 'Home',
component: () => import('../views/Home/Home.vue')
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About/About.vue')
},
]
},
]
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
//home页面<template>
<div class="hhh">
<img alt="Vue logo" src="https://segmentfault.com/assets/logo.png" />
</div>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
export default class Home extends Vue {}
</script>
<style lang="less">
</style>
//主页面,就是有router-view的,app.vue中只有一个router-view<template>
<div class="home">
<div id="nav">
<router-link to="/home">Home</router-link> |
<router-link to="/about">About</router-link> |
<router-link to="/login">login</router-link>
</div>
<router-view />
</div>
</template>
回答
你的Login页面呢?
以上是 vue路由改变,页面不变? 的全部内容, 来源链接: utcz.com/a/46202.html