Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

echarts 的 getInstanceByDom 无法正常获取到实例 #740

Closed
1 task done
twt898xu opened this issue Oct 7, 2023 · 3 comments
Closed
1 task done

echarts 的 getInstanceByDom 无法正常获取到实例 #740

twt898xu opened this issue Oct 7, 2023 · 3 comments

Comments

@twt898xu
Copy link

twt898xu commented Oct 7, 2023

请确认

  • 我可以确认这个问题无法在 ECharts 项目本身中复现。

您是如何将 Vue-ECharts 引入项目的?

通过 ES 模块 import

版本信息

vue-echarts:6.6.1

问题详情

image

最新的vue-echarts生成的dom

echarts_instance 这个属性在 内部的DIV元素上而不是在 x-vue-echarts这个元素上,导致 getInstanceByDom 方法无法通过 x-vue-echarts 拿到chat实例。这与之前版本的表现不同

问题复现

none

@Justineo
Copy link
Member

Justineo commented Oct 7, 2023

Vue-ECharts 并不对外保证自身的 DOM 结构,所以这并不是一个 bug。你是用 getInstanceByDom 的场景是什么?

@twt898xu
Copy link
Author

twt898xu commented Oct 8, 2023

@Justineo 通过实例的 getOption 方法来获取配置。之前逻辑类似于 getInstanceByDom(document.querySelector('x-vue-echarts')).getOption() 6.6.1之后得修改成 getInstanceByDom(document.querySelector('x-vue-echarts').firstChild).getOption()

@twt898xu twt898xu changed the title ecgarts 的 getInstanceByDom 无法正常获取到实例 echarts 的 getInstanceByDom 无法正常获取到实例 Oct 8, 2023
@Justineo
Copy link
Member

Justineo commented Oct 8, 2023

你可以用 ref 获取组件实例,上面有 getOption 方法。

@Justineo Justineo closed this as completed Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants