vue3.0 选项式api 使用 mounted 钩子?

提示信息如下

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.

image.png

阅读 3.4k
2 个回答

截图不全,但这个报错提示是说你用 async setup 函数,但是onMounted 不在第一个await 之前

报的是异步方法使用不当。还有就是都用vue3.0,就不要出现选项式API了,要用就降回2.x

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题