Няма описание

scorpio 55f1e4a212 init преди 1 година
.vscode 7c1504e3cf scss + pinia + axios преди 2 години
public 7c1504e3cf scss + pinia + axios преди 2 години
src 55f1e4a212 init преди 1 година
.eslintrc.cjs 75dfd03455 yulan преди 1 година
.gitignore 7c1504e3cf scss + pinia + axios преди 2 години
.prettierrc.cjs 55f1e4a212 init преди 1 година
README.md 046ad48941 fix keepAlive преди 2 години
components.d.ts 55f1e4a212 init преди 1 година
index.html 55f1e4a212 init преди 1 година
package.json 55f1e4a212 init преди 1 година
vite.config.js 50c1594733 yulan преди 1 година
yarn.lock 55f1e4a212 init преди 1 година

README.md

设置keepAlive

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

export default {
  name: '设置', // 需要设置页面name 和 rotue 中的name 一致
  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>