方法一: 去掉Content Security Policy
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title></title>
</head>
<body>
<script>
(省略号)
</script>
</body>
</html>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
方法二:不采用内联
方法三:修改CSP,列出允许执行的脚本代码的Hash值
转载:https://www.cnblogs.com/xkxf/p/15553510.html
错误
<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()
}
})
})