【报错】onMounted is called when there is no active component instance too be associated with.

简介: 【报错】onMounted is called when there is no active component instance too be associated with.

@[toc]

报错

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

分析

import {onMounted } from 'vue' 之后使用

onMounted(()=>{
   
    fetchData()
})

使用了Vue3的写法但并未遵从Vue3的格式

解决

如果没有用到export就需要用到语法糖
写法如下

<script setup lang="ts">
    import {
   onMounted } from 'vue'
    onMounted(()=>{
   
        fetchData()
    })
</script>
相关文章
|
6月前
|
JavaScript
Property “selectedItemIndex“ was accessed during render but is not defined on instance. 报错解决
Property “selectedItemIndex“ was accessed during render but is not defined on instance. 报错解决
604 0
|
6月前
|
NoSQL 编译器 API
关于thread使用的错误:pure virtual method called terminate called without an active exception
关于thread使用的错误:pure virtual method called terminate called without an active exception
114 1
|
6月前
Error:Execution failed for task ':app:javaPreCompileDebug'. > Annotation processors must be explicit
Error:Execution failed for task ':app:javaPreCompileDebug'. > Annotation processors must be explicit
91 0
Unknown custom element: <add-employee> - did you register the component correctly? For red cursive c
原因: 1.组件名没写对(导入和注册不对应) 2.components少写了个s 3.组件命名最好是驼峰命名 4.导入时语法错误 5.代码中有两个components,后一个的值把前一个覆盖了 6.组件直接循环套用了
|
11月前
|
JavaScript
[Vue warn]: Unknown custom element: <Top> - did you register the component correctly?
[Vue warn]: Unknown custom element: <Top> - did you register the component correctly?
|
Java Spring
【新手指南】严重: Exception sending context initialized event to listener instance of class
【新手指南】严重: Exception sending context initialized event to listener instance of class
501 0
【新手指南】严重: Exception sending context initialized event to listener instance of class
|
Java 编译器 Spring
报错:No fallback instance of type class**解决办法
报错:No fallback instance of type class**解决办法
1063 0
报错:No fallback instance of type class**解决办法
|
JavaScript 算法 前端开发
Property xxx was accessed during render but is not defined on instance
目前el-form的model主要用表单验证的,也就是配合el-form的rules和el-form-item的prop来使用的。不信的话,你可以增加一个rules和prop(为了调用验证方法,也el-form也加一个ref属性,相当于id或者class选择器的意思),但是不写model,然后验证的话,会提示缺少model,导致无法验证成功。
Property xxx was accessed during render but is not defined on instance