纯小白,有没有vue2+for Cesium的整合代码,特别是怎么引入的,我下载了开发包之后再index.html引入没有效果,尝试了动态引入也没有效果(这个不知道是不是路径写的有问题,开发包在public/static/cesium),有没有环境调试好的老哥给点建议
getCesiumScript(CesiumPath, prettycsspath) {
try {
if (!window.Cesium) {
//widgets样式
let $widgetslink = document.createElement("link");
$widgetslink.rel = "stylesheet";
window.document.head.appendChild($widgetslink);
$widgetslink.href = CesiumPath + "/Widgets/widgets.css";
//pretty样式
// let $prettycsspath = document.createElement("link");
// $prettycsspath.rel = "stylesheet";
// window.document.head.appendChild($prettycsspath);
// $prettycsspath.href = prettycsspath;
console.log("dsdsadasas")
//Cesium.js资源
let $Cesiumscript = document.createElement("script");
window.document.body.appendChild($Cesiumscript);
$Cesiumscript.type = "text/javascript";
$Cesiumscript.src = CesiumPath + "/Cesium.js";
console.log($Cesiumscript)
return new Promise((resolve, reject) => {
$Cesiumscript.onload = () => {
if (window.Cesium) {
resolve(window.Cesium);
} else {
reject(console.log("load failed"));
}
};
});
}
} catch (err) {
}
},
//异步加载资源,等同于promise,资源路径存放在globe.js中
async beforeInit() {
await this.getCesiumScript('@/../public/static/Cesium/', '');
},