在Vue后台管理系统中,你可以通过路由来实现页面间的跳转,并且可以通过配置路由的meta字段来实现已经打开页面的复用。

首先,在你的路由配置文件中,可以将meta字段设置为keepAlive:true,表示该页面需要进行缓存。例如:

const routes = [
  {
    path: '/page1',
    name: 'Page1',
    component: Page1,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/page2',
    name: 'Page2',
    component: Page2,
    meta: {
      keepAlive: true
    }
  }
]

接下来,在页面跳转的时候,可以使用<router-link>this.$router.push()等方式进行跳转。例如:

<template>
  <div>
    <router-link to="/page1">跳转到Page1</router-link>
    <button @click="gotoPage2">跳转到Page2</button>
  </div>
</template>

<script>
export default {
  methods: {
    gotoPage2() {
      this.$router.push('/page2')
    }
  }
}
</script>

这样,当你从一个页面跳转到另一个页面时,如果目标页面已经打开,则不会重新打开,而是复用已有的页面实例。这样可以提高页面的加载速度和用户体验

vue后台管理系统页面 从一个页面跳转另一个页面如果已经打开就不重新打开

原文地址: https://www.cveoy.top/t/topic/hQE2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录