首页 > 其他分享 >vue3 onMounted is called when there is no active component

vue3 onMounted is called when there is no active component

时间:2022-08-26 10:33:28浏览次数:108  
标签:no when setup there component onMounted

Vue 版本:3.0.0
出现的问题:

在 setup() 中 onMounted() onActivated(),出现警告:
[Vue warn]: onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.

[Vue warn]: onActivated is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.

页面初始加载时,也不执行钩子函数

解决办法:

将 onMounted() onActivated() 代码提前,放在 setup()函数的最前端,神奇的好了。

原因: 未知

不知新版本 vue3.2,会不会出现这个问题

标签:no,when,setup,there,component,onMounted
From: https://www.cnblogs.com/zhanglw456/p/16626658.html

相关文章

  • Python爬虫 AttributeError: 'NoneType' object has no attribute 'replace'
    在爬虫时执行js代码报错node=execjs.get()ctx=node.compile(js_code).call('webInstace.shell',data)  点击1处进入subprocess.py文件   把encoding=Non......
  • django2.x -- auth模块的authenticate方法一直返回None,认证不成功
    创建用户时是否使用的是create_user在账号注册的时候,要用objects.create_user()函数,create()是明文存储create_user()这个函数会将密码自动加密,密文存储,加密规则“pbkdf......
  • CentOS8错误:为仓库 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlis
    CentOSLinux8在2022年12月31日来到生命周期终点(EndofLife,EoL)。即CentOSLinux8操作系统版本结束了生命周期(EOL),Linux社区已不再维护该操作系统版本。所以原来的CentOS......
  • P1399 [NOI2013] 快餐店 题解
    题目大意求一棵基环树的重心。即一个点,使得树上到其距离最长的点到其的距离最短。注意,这个点不一定是一个节点,可以在树上的任意位置。输出树上到其距离最长的点到其的距离......
  • [Note] POI 板刷寄录 II
    来点大紫大黑[POI2013]LUK-TriumphalarchA的窝火。显然是二分,树形dpcheck一下即可。这边证伪一下一种贪心check:首先我们从根节点\(1\)开始dfs全树。同时记......
  • Uncaught Error: Cannot find module './components/xxxx.vue'
    导入组件报异常,有可能两个原因:在组件文件中里面的exportdefault{name:"这里有时候忘记加双引号"}就会找不到该组件在vsCode编辑器中,对vue组件进行重命名,如testcom......
  • arduino自定义库c与c++的区别
    起初是想把手头的红牛开发板的基于stm32标准库的例子都改成用arduino库的   发现arduino库是基于hal库的 不是直接把c文件挪过来就能用的arduino是c++编译器 如......
  • NOI2022退役游记
    @目录@目录游记部分前言Day0Day1Day2Day3Day4Day5退役感想游记部分前言在当天记录一下每一天,这样也许会真实具体一点,也许最后会删掉。Day0前一天晚上做了一个梦,梦到自......
  • npm 安装依赖包,报错 install: `node-gyp rebuild` 解决方法
    错误现象这是 配置环境变量 的问题核对下 环境变量 NODE_PATHC:\nodejs\node_global\node_modules   ......
  • Plugin with id 'maven' not found
    引入maven插件出问题了,总是报错找不到maven插件。Causedby:org.gradle.api.plugins.UnknownPluginException:Pluginwithid‘maven’notfound.原因分析:这是关于......