首页 / 浏览问题 / 三维GIS / 问题详情
index。js引入js文件后运行报错
yjw
15EXP 2022年11月23日
index。html
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <link rel="icon" href="<%= BASE_URL %>favicon.ico">
  <title>模型查看</title>
  <link href="./Cesium/Widgets/widgets.css" rel="stylesheet">
  <script src="./Cesium/Cesium.js"></script>
  <script src="./jquery.min.js"></script>
  <script type=" text/javascript" src="./require.min.js" data-main="js/main"></script>
</head>
====
export default {
  name: 'HelloWorld',
  methods: {
    query: function () {
      var promise = scene.open("http://localhost:8090/iserver/services/3D-DaoDongShuJu/rest/realspace")
      Cesium.when.all(promise, function (layer) {
        layer = scene.layers.find('test');
        // console.log(layer)
        layer.indexedDBSetting.isAttributesSave = true;
        // var a = layer.getAttributesById(17);
        // console.log(a);
        var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); //设置鼠标左键单击回调事件
        handler.setInputAction(function (e) {
          console.log("handler")
          var ids = layer.getSelection();
          console.log(ids);
          for (var i = 0; i < ids.length; i++) {
            layer.getAttributesById(ids[i]).then(function (data) {
              console.log(data);
            });
          }
        }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
      },
        function (e) {
          if (widget._showRenderLoopErrors) {
            var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
            widget.showErrorPanel(title, undefined, e);
          }
        })
    },
  }
  }

1个回答

您好,

您的报错内容是什么呢?

是否有检查路径下的js文件呢?
4,151EXP 2022年11月23日
require.min.js:1060          GET http://localhost:8080/js/main.js net::ERR_ABORTED 404 (Not Found)
req.load @ require.min.js:1060
load @ require.min.js:884
load @ require.min.js:434
fetch @ require.min.js:423
check @ require.min.js:501
enable @ require.min.js:658
enable @ require.min.js:823
(anonymous) @ require.min.js:647
(anonymous) @ require.min.js:53
each @ require.min.js:15
enable @ require.min.js:610
init @ require.min.js:411
(anonymous) @ require.min.js:774
setTimeout (async)
req.nextTick @ require.min.js:1001
o @ require.min.js:771
configure @ require.min.js:730
requirejs @ require.min.js:991
(anonymous) @ require.min.js:1130
(anonymous) @ require.min.js:1132
localhost/:1 Refused to execute script from 'http://localhost:8080/js/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
require.min.js:73 Uncaught Error: Script error for "main"
http://requirejs.org/docs/errors.html#scripterror
    at makeError (require.min.js:73:13)
    at HTMLScriptElement.onScriptError (require.min.js:911:17)
makeError @ require.min.js:73
onScriptError @ require.min.js:911
error (async)
req.load @ require.min.js:1052
load @ require.min.js:884
load @ require.min.js:434
fetch @ require.min.js:423
check @ require.min.js:501
enable @ require.min.js:658
enable @ require.min.js:823
(anonymous) @ require.min.js:647
(anonymous) @ require.min.js:53
each @ require.min.js:15
enable @ require.min.js:610
init @ require.min.js:411
(anonymous) @ require.min.js:774
setTimeout (async)
req.nextTick @ require.min.js:1001
o @ require.min.js:771
configure @ require.min.js:730
requirejs @ require.min.js:991
(anonymous) @ require.min.js:1130
(anonymous) @ require.min.js:1132
require.min.js:1060          GET http://localhost:8080/js/main.js net::ERR_ABORTED 404 (Not Found)
req.load @ require.min.js:1060
load @ require.min.js:884
load @ require.min.js:434
fetch @ require.min.js:423
check @ require.min.js:501
enable @ require.min.js:658
enable @ require.min.js:823
(anonymous) @ require.min.js:647
(anonymous) @ require.min.js:53
each @ require.min.js:15
enable @ require.min.js:610
init @ require.min.js:411
(anonymous) @ require.min.js:774
setTimeout (async)
req.nextTick @ require.min.js:1001
o @ require.min.js:771
configure @ require.min.js:730
requirejs @ require.min.js:991
(anonymous) @ require.min.js:1130
(anonymous) @ require.min.js:1132
localhost/:1 Refused to execute script from 'http://localhost:8080/js/main.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
require.min.js:73 Uncaught Error: Script error for "main"
http://requirejs.org/docs/errors.html#scripterror
    at makeError (require.min.js:73:13)
    at HTMLScriptElement.onScriptError (require.min.js:911:17)

这样报错

麻烦大佬看一下

看报错:“ 拒绝执行来自'http://localhost:8080/js/main.js'的脚本,因为它的MIME类型('text/html')是不可执行的,并且启用了严格的MIME类型检查。

该错误出现可能性较多,且不是我们的webgl包出现的缺陷问题,建议您这边通过其他途径以及报错信息去找寻具体的原因,其中之一的情况可以参考:https://blog.csdn.net/JIANtype/article/details/104845404/

...