[Violation] Avoid using document.write().

当使用HBuilderX编辑器并启用'保存自动刷新浏览器'功能时,会在文件的</body>标签前注入刷新脚本,引发页面报错。解决办法是取消该选项,避免自动刷新。这一设置有助于开发者在不打断工作流程的情况下查看代码更新的效果。

用HBuilder X编辑器的伙伴可能见过以下这个报错:

当你按照它定位报错所在的行看去时只能看到一个光秃秃的

</body>

小搜了一下只看到国内一个论坛给了答案:

只需要把这个勾去掉,取消自动刷新即可。

原因分析:

在选择 '保存自动刷新浏览器' 选项时,HBuilder X原文件</body>前注入了这么一段脚本实现保存重新加载页面,方便开发者查看效果。

自: 【报Bug】HBuilderX 本地服务器往页面注入的脚本不能关闭 - DCloud问答

[Violation]Avoid using document.write(). [Violation]Avoid using document.write(). [Violation]Avoid using document.write(). [Violation]Avoid using document.write(). [Violation]Avoid using document.write(). [Violation]Avoid using document.write(). [Violation]Avoid using document.write(). [Violation]Avoid using document.write(). SuperMap.Include.js:1 [Violation]Parser was blocked due to document.write(<script>) i @ SuperMap.Include.js:1 (匿名) @ SuperMap.Include.js:1 (匿名) @ SuperMap.Include.js:1 SuperMap.Include.js:1 [Violation]Parser was blocked due to document.write(<script>) i @ SuperMap.Include.js:1 (匿名) @ SuperMap.Include.js:1 (匿名) @ SuperMap.Include.js:1 SuperMap.Include.js:1 [Violation]Parser was blocked due to document.write(<script>) i @ SuperMap.Include.js:1 (匿名) @ SuperMap.Include.js:1 (匿名) @ SuperMap.Include.js:1 :9933/#/login:1 [Intervention]Slow network is detected. See https://www.chromestatus.com/feature/5636954674692096 for more details. Fallback font will be used while loading: http://192.168.1.203:9933/static/b462afa2d5b52ed52701.otf 2030.79df9936.js:2 production stomp.min.js:1 Opening Web Socket... 2030.79df9936.js:2 $keepAliveViews Proxy(Array) {} 2030.79df9936.js:2 {fullPath: '/login', path: '/login', query: {…}, hash: '', name: 'Login', …} '------------------' 2030.79df9936.js:2 $keepAliveViews Proxy(Array) {} :9933/#/login:1 [Intervention]Slow network is detected. See https://www.chromestatus.com/feature/5636954674692096 for more details. Fallback font will be used while loading: http://192.168.1.203:9933/static/150b8ee34940fba3a3d1.otf :9933/#/login:1 Access to XMLHttpRequest at 'https://192.168.1.203:8084/endpointOyzc/info?t=1751355305204' from origin 'http://192.168.1.203:9933' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'http://192.168.1.203:9933, *', but only one is allowed. 2030.79df9936.js:2 GET https://192.168.1.203:8084/endpointOyzc/info?t=1751355305204 net::ERR_FAILED 200 (OK) r._start @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 setTimeout r @ 2030.79df9936.js:2 n @ 2030.79df9936.js:2 n @ 2030.79df9936.js:2 n._getReceiver @ 2030.79df9936.js:2 n.doXhr @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 setTimeout n @ 2030.79df9936.js:2 r @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 e @ 2030.79df9936.js:2 29863 @ 2030.79df9936.js:2 o @ runtime.0a6e0595.js:1 (匿名) @ 2030.79df9936.js:2 Promise.then 1863 @ 2030.79df9936.js:2 o @ runtime.0a6e0595.js:1 Promise.then 68138 @ main.f0bca0c4.js:1 o @ runtime.0a6e0595.js:1 (匿名) @ main.f0bca0c4.js:1 a @ runtime.0a6e0595.js:1 (匿名) @ main.f0bca0c4.js:1 stomp.min.js:1 Whoops! Lost connection to https://192.168.1.203:8084/endpointOyzc 2030.79df9936.js:2 Establish error: Whoops! Lost connection to https://192.168.1.203:8084/endpointOyzc config @ 2030.79df9936.js:2 (匿名) @ stomp.min.js:1 n.dispatchEvent @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 setTimeout r._close @ 2030.79df9936.js:2 r._receiveInfo @ 2030.79df9936.js:2 i @ 2030.79df9936.js:2 n.emit @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 i @ 2030.79df9936.js:2 n.emit @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 i @ 2030.79df9936.js:2 n.emit @ 2030.79df9936.js:2 xhr.onreadystatechange @ 2030.79df9936.js:2 XMLHttpRequest.send r._start @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 setTimeout r @ 2030.79df9936.js:2 n @ 2030.79df9936.js:2 n @ 2030.79df9936.js:2 n._getReceiver @ 2030.79df9936.js:2 n.doXhr @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 setTimeout n @ 2030.79df9936.js:2 r @ 2030.79df9936.js:2 (匿名) @ 2030.79df9936.js:2 e @ 2030.79df9936.js:2 29863 @ 2030.79df9936.js:2 o @ runtime.0a6e0595.js:1 (匿名) @ 2030.79df9936.js:2 Promise.then 1863 @ 2030.79df9936.js:2 o @ runtime.0a6e0595.js:1 Promise.then 68138 @ main.f0bca0c4.js:1 o @ runtime.0a6e0595.js:1 (匿名) @ main.f0bca0c4.js:1 a @ runtime.0a6e0595.js:1 (匿名) @ main.f0bca0c4.js:1 :9933/#/login:1 [DOM] Password field is not contained in a form: (More info: https://www.chromium.org/developers/design-documents/create-amazing-password-forms) <input type=​"password" name=​"password" class=​"IZY4NP9Uc0CXwohzTFYD" placeholder=​"请输入密码">​ stomp.min.js:1 Opening Web Socket...
07-02
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值