zouyaoji / vue-cesium

🎉 Vue 3.x components for CesiumJS.
https://zouyaoji.top/vue-cesium
MIT License
1.49k stars 321 forks source link

路由页面this获取Cesium,viewer为undefined #52

Closed loyalove closed 4 years ago

loyalove commented 4 years ago

[BUG 反馈] 路由页面this获取Cesium,viewer为undefined

浏览器版本号

QQ浏览器10.5.2

Vue 版本号

2.6.11

组件库版本号

1.0.6

现象描述

建议优化:
vue-cesium/src/mixins/common.js#getParent

原代码:
const getParent = $component => {
  $component.abstract || $component.$el === $component.$children[0].$el ? getParent($component.$parent) : $component
}

优化后:
const getParent = $component =>
    !$component.cesiumClass && $component.$options.name !== 'cesium-viewer' ? getParent($component.$parent) : $component

完整异常信息

this.Cesium为undefined,this.viewer为undefined

在线示例 / 仓库 URL

复现用例

CesiumViewer定义在布局文件,页面this获取Cesium,viewer为undefined

预期输出

Cesium对象

实际输出

viewer对象
zouyaoji commented 4 years ago

你好,有点没看懂,“CesiumViewer定义在布局文件,页面this获取Cesium,viewer为undefined”。具体能上传个小demo我看看吗?

zouyaoji commented 4 years ago

哦 你用的 1.0.6版本? 最新的已经改过了哈

loyalove commented 4 years ago

我们项目用的1.x版本,能不能修复发一个1.x版本呢?

zouyaoji commented 4 years ago

不好意思啊,npm不支持这样操作,改bug只能升版本,只不过2的版本我重命名了组件,改起来可能麻烦点,但其他优化的东西还是多的。 你根据情况决定是否升级吧。