vue.js - 如何在 vue3.x 中创建类似 KeepAlive 的组件
问题描述
版本
3.1.2
转载链接
https://github.com/hezhongfeng/vue-page-stack/tree/next
重现步骤
我不喜欢 Vue 的 KeepAlive 缓存策略,所以我想创建一个类似 KeepAlive 的组件。但是当我将我的组件与 一起使用时transition
,出现了错误Uncaught TypeError: Cannot read property '_' of null
。此错误是由packages/runtime-core/src/componentSlots.ts
initSlots 创建的。我不知道如何解决它。
const KKeepAliveImpl: ComponentOptions = {
name: `KKeepAlive`,
__isKeepAlive: true,
setup(props, { slots }: SetupContext) {
return () => {};
},
};
const KKeepAlive = KKeepAliveImpl as any as {
__isKeepAlive: true;
new (): {
$props: VNodeProps;
};
};
有人有想法吗?
解决方案
推荐阅读
- python - 使用 PYTHON 通过 ssh 发送 cqlsh 命令的正确方法
- excel - 将所有切片器连接到所有数据透视表
- javascript - FlexBox 容器没有容纳我的 div,有人可以回答我为什么吗
- javascript - 将 Mongodb 集合中的实例保存为 Atlas 触发器函数中的字符串变量
- next.js - 为什么在下一个 js 中使用 getStaticProps 获取 API 数据时显示加载屏幕?
- ios - Flutter run crash on IOS Error running pod install
- nginx - Nginx 无法从 cookie 验证 JWT
- python - Python 默认字典行为
- docker - 是否可以从 Docker 访问 localhost?
- r - R组的分位数