Sin descripción

scorpio 6f85d64394 fix bug hace 2 años
.vscode 7c1504e3cf scss + pinia + axios hace 3 años
public 7c1504e3cf scss + pinia + axios hace 3 años
src 6f85d64394 fix bug hace 2 años
.eslintrc.cjs aeeb3853ec 年度投资 hace 2 años
.gitignore 7c1504e3cf scss + pinia + axios hace 3 años
.prettierrc.cjs aeeb3853ec 年度投资 hace 2 años
README.md 61bbd02f9e fix hace 3 años
index.html 71f886877a fix bug hace 2 años
jsconfig.json aeeb3853ec 年度投资 hace 2 años
package.json 111dbf2049 fix bug hace 2 años
vite.config.js 95fa9bd886 fix bug hace 2 años
yarn.lock 111dbf2049 fix bug hace 2 años

README.md

设置keepAlive

// 配置代码
<route>
  {
    name: '设置',
    meta: { keepAlive: true }
  }
</route>
//
<script>

export default {
  name: '设置', // 需要设置页面name 和 rotue 中的name 一致,keepAlive 才有效
  data () {
    return {
      data: { }
    }
  },
  // ...

// 实现逻辑代码
// /router/index.js
if (to.meta.keepAlive) {
  const keepAlive = keepAliveStore()
  keepAlive.add(to.name) // 将路由名称添加到 keepAlive 集合中
}
// /layout/index.vue
<router-view v-slot="{ Component, route }">
  <keep-alive :include='keepAlive.list'>
    <component :is="Component" :key="route.fullPath" />
  </keep-alive>
</router-view>