<template> <div id="app" class="container"> <router-view v-slot="{ Component }"> <keep-alive :include="['peopleList', 'addressList']"> <component :is="Component" /> </keep-alive> </router-view> </div> </template>
peopleList.vue
defineOptions({ name: 'peopleList' })
defineOptions 插件
vue3 setup 语法糖配置 name 属性需要使用 defineOptions 插件
pnpm i unplugin-vue-define-options
vite.config.js
import DefineOptions from 'unplugin-vue-define-options/vite' plugins: [ DefineOptions(), ]
tsconfig.json
{ "compilerOptions": { "types": ["unplugin-vue-define-options/macros-global"] }, }
标签:vue,defineOptions,alive,keep,unplugin,vue3,options,define From: https://www.cnblogs.com/CyLee/p/16968035.html