Vue报错 Error in destroyed hook: "TypeError: xxx is not a function”

发布时间 2023-08-30 19:34:23作者: ridiculousknight

问题

将项目npm run build打包以后,进入项目本地文件夹dist,打开index.html,页面空白并且报如下错误

image

解决

中文搜索找到的相关内容都没有解决问题,还是stack overflow稳

vue.js - [Vue warn]: Error in created hook: "TypeError: $ is not a function" - Stack Overflow

所以问题的根源很可能是一个typo(打字错误)

我又仔细看了一遍相关代码,确实是typo,生命周期钩子mounted被我写成了monuted

改正之后,页面正常显示且不再报错