vue编程经验

1.

[Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'state')"

原因:如果不是语法错误,可能的原因是vuex的版本不匹配

解决办法:安装合适版本的vuex。我改安装成"vuex": "^3.6.2",错误被解决。

 

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

在 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()函数的最前端(可以在 useI18n(), useRoute() 等之后),神奇的好了。

原因: 未知

posted @ 2022-08-07 00:42  银河1992  阅读(1297)  评论(0编辑  收藏  举报