我将超图官网下载的2024版本的cesium下载下来之后,将里面的build文件下的Cesium文件都复制到vue项目的这个包里面了,代码如下:
<!-- * @Author: huang * @Date: 2024-06-27 22:45:28 * @LastEditors: 15779269969 48022055+15779269969@users.noreply.github.com * @LastEditTime: 2024-07-10 21:48:59 * @FilePath: \3-d-alpha\src\views\oneMap\index.vue * @Description: * * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. --> <template> <div> <div id="cesiumContainer" class="fullSize"></div> <div id="toolbar"></div> </div> </template> <script> import { defineComponent, onMounted } from "vue"; import "cesium/Build/Cesium/Widgets/widgets.css"; import * as Cesium from "cesium"; // import * as SuperMap3D from "cesium/Build/SuperMap3D/SuperMap3D.js"; export default defineComponent({ name: "OneMap", setup() { const getCesium = () => { Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMmJkMzNkMS01OWVjLTRkMzUtYmVkYy03YzU1MDM3OWRmYjYiLCJpZCI6MTkzMzAyLCJpYXQiOjE3MjA0Mjk2Mzh9.MoKA5NmBbB2vtaAD-rCTU_22LpoTW1L4uyJFfIeFF-E"; const viewer = new Cesium.Viewer("cesiumContainer"); const promise = viewer.scene.open( "http://www.supermapol.com/realspace/services/3D-CBD/rest/realspace" ); }; onMounted(() => { getCesium(); }); return { getCesium, }; }, }); </script> <style lang="scss" scoped> #cesiumContainer { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; } </style>
但是仍然加载服务不成功