cesiumjs 报错 Blocked script execution in 'about:blank'

CesiumJs yekong 537℃

当我们成功安装运行cesium后,会有一个信息提示:

Blocked script execution in 'about:blank' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.

百度翻译后:

“about:black”中的脚本执行被阻止,因为文档的框架是沙盒,并且未设置“允许脚本”权限。

方法1 去掉infoBox

如果我们希望去掉这一条信息提示的话可以使用infoBox去掉它。

onMounted(() => {
  var viewer = new Cesium.Viewer('cesiumBody', {
    infoBox: false
  })
})

方法2 允许运行脚本


// 设置沙箱允许使用js
var iframe = document.getElementsByClassName("cesium-infoBox-iframe")[0];
iframe.setAttribute(
"sandbox",
"allow-same-origin allow-scripts allow-popups allow-forms"
);
iframe.setAttribute("src", "");

当前内容为观看threejs视频教程 Three.js可视化企业实战WEBGL课 课程-Cesium基础设置-学习笔记

笔记汇总

Cesium学习笔记汇总

喜欢 (0)