Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem:". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

原因是 Chrome 插件不支持在插件的 html 上写内联 js, 如果需要添加事件,可以再外联 js 中写入:

错误的写法:

<div class="switch-box">
   <input class="switch-input" onchange="beautyUI()" type="checkbox" />
</div>

正确的写法

<div class="switch-box">
   <input class="switch-input" value="beautyUI" type="checkbox" />
</div>
$(function () {
  $('.switch-input').change(function () {
    var value = $(this).val()
    if (value === 'beautyUI') {
      beautyUI()
    }
  })
})

相关文章:

  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-12-16
  • 2021-07-05
  • 2021-06-13
  • 2021-07-26
  • 2022-12-23
猜你喜欢
  • 2021-08-09
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2021-11-21
  • 2022-12-23
相关资源
相似解决方案