关于控制台报错ReferenceError: MutationEvent is not defined的解决方案

首先搞清楚为什么会出现这个东西,明明编写的js代码符合规范,并且也都声明了,怎么还会出现这个问题,我也查看了许多的资料,包括csdn的及其github上的,最终都没有的到一个解决的方案,无意间发现了解决的方案,顺便记下来,以便给有这个问题的各位程序员兄弟们提供方法。

以下为代码(并没有其他规范问题)

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="box">哈哈</div>
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
  </ul>
  <div class="wrapper">我是wrapper</div>


  <script>
    var bodyEl=document.body
    var childEl=bodyEl.children
    console.log(childEl)

    var childElfirst=bodyEl.firstElementChild
    console.log(childElfirst)

  </script>
</body>
</html>

报错的结果:

但是还是会正确的显示结果

所以解决的就只是下面这个(当然也可以不解决,但是后期不知道会不会有影响)

Uncaught ReferenceError: MutationEvent is not defined
    at e (VM69 content.js:2:169)
    at VM69 content.js:7:33
    at VM69 content.js:61:414
    at VM69 content.js:61:419

我就是单纯看它不爽,然后解决

解决方法--》找到自己浏览器上的设置--》拓展(拓展程序)--》找到篡改猴--》关闭掉--》回到网页刷新--》完美解决

后续要是有其他方案会持续更新

  • 14
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
引用中提到的解决方法是在vue.config.js中添加一些配置,其中使用了webpack的ProvidePlugin插件来提供全局的jquery变量。这样就能解决报错"ReferenceError: $ is not defined"的问题。中提到的报错提示不是由于没有使用lib:["dom"]造成的,而是在类型注释中使用了MouseEvent。在这种情况下,没有问题的。中指出,如果项目中引用了.eslintrc.js文件,还需要在文件的module.exports中为env添加一个键值对jquery: true,然后重新启动项目。这样也可以解决报错"ReferenceError: $ is not defined"的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Vue引入JQuery报错caught ReferenceError: jQuery is not defined](https://blog.csdn.net/qq_46034741/article/details/130032090)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [vue ssr 报错 ReferenceError: MouseEvent is not defined / window is not defined 等等](https://blog.csdn.net/qq_28550263/article/details/130152398)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Vue小知识: $ is not defined错误解决](https://blog.csdn.net/weixin_43945983/article/details/88294052)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值