【发布时间】:2022-09-28 18:31:21
【问题描述】:
我正在为我的网站使用 nuxt3 和 vue3。 但是我在使用 onMounted 钩子时遇到了问题。
这是我的Vue页面。
<script setup lang=\"ts\">
import { onMounted } from \'@vue/runtime-core\';
onMounted(() => {
console.log(\'myheader mounted\');
})
</script>
<template>
<h1>test</h1>
</template>
我得到这个错误:
[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.
搞得我一头雾水……T.T
标签: vue.js nuxt.js vuejs3 server-side-rendering nuxtjs3