-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
热更新报错 TypeError: parentComponent.ctx.deactivate is not a function #6222
Comments
vue@3.2.37 , vue-router@4.0.16, vite@2.9.13 , @vitejs/plugin-vue@2.3.3 TypeError: parentComponent.ctx.deactivate is not a function |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
盲猜你是把 component 套了自定义组件里了,导致找不到 keepalive 实例,所以 |
我之前的描述反了,应该是当 router-view 把 keep-alive 包裹 我用 keep-alive 是为了 App.vue <script setup>
</script>
<template>
<router-view v-slot="{ Component }">
<!-- TODO keep-alive 路由回退需要清除缓存 -->
<keep-alive>
<component
:is="Component"
:key="$route.fullPath"
/>
</keep-alive>
</router-view>
</template>
<style lang="scss" scoped></style> router.ts router.beforeEach((to, from, next) => {
if (!to.query.t) {
to.query.t = new Date().getTime().toString();
return next(to);
}
next();
}); |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
same error |
saaaaaaaaaaaaaaaaaaaame error |
same error |
1 similar comment
same error |
我也是同样的问题,ctrl+s保存就报错, |
same error! |
same |
same error!!! |
请问有解决方法吗 |
请问有解决方案吗 |
same error |
升级chrome到最新版本可以解决,但还是有些场合无法升级浏览器版本。 |
同样的报错,chrome 版本是 100 |
一个笨拙的解决办法,将报错的.vue文件当成一个组件,然后新建一个index.vue引入这个组件。 |
chrome 105.0.5195.102 依然存在该问题 |
关浏览器什么事 |
我也觉得和浏览器无关,试了好几个vue旧版本,有的版本即使控制台不报错,KeepAlive的页面,多次切换或热更新显示也有异常 |
换了最新的 chrome 浏览器,也一样报错 |
Temporary Solutions 临时解决方案 <template v-if="NODE_ENV !== 'development'">
<keep-alive>
<component :is="Component" :key="route.fullPath" />
</keep-alive>
</template>
<template v-else>
<component :is="Component" :key="route.fullPath" />
</template> vue-cli const NODE_ENV = process.env.NODE_ENV vite <template v-if="!DEV"> const DEV = import.meta.env.DEV; |
你这个不一定是vue的问题,可能是echarts的问题。你这个问题,不附代码,没法定位。 |
这个是有问题的代码工程: |
今天没时间看,后面有时间我看一下吧,看了可能也解决不了问题。 |
@midfar 看下这个能不能用 #4339 (comment) 自己给 keep-alive 包裹的 component 包个壳。 |
你这样改貌似可以,但是控制台有另一个警告(好像不影响功能) |
@midfar 贴下你的代码看下。 |
已上传到这里,注意是keep-alive分支。开发模式下,登录后可以看到控制台警告 |
@midfar 你别把壳组件集合放到响应式数据里,这里改一改。 你在你的 |
恩,可以了,牛逼啊 |
加壳的操作,有点复杂,而且意义也不明确,最好官方能支持,不用我们加这么多代码 |
same error |
楼上大佬已经解决了呢 |
加markRaw就没警告了,return h(markRaw(wrapper)); |
官方还没有解决方案么 |
+1 |
same error |
Uncaught (in promise) TypeError: parentComponent.ctx.deactivate is not a function |
This comment was marked as off-topic.
This comment was marked as off-topic.
same error |
Vue version
3.2.25
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-xqwn2n?file=src/components/HelloWorld.vue
Steps to reproduce
当修改usePage函数的参数
What is expected?
页面发生修改
What is actually happening?
parentComponent.ctx.deactivate is not a function
System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: