ecomfe / vue-echarts

Vue.js component for Apache ECharts™.
https://vue-echarts.dev
MIT License
9.75k stars 1.49k forks source link

Event listener not working in Vue 2.7 #636

Closed kingyue737 closed 2 years ago

kingyue737 commented 2 years ago

Confirmation

How are you introducing Vue-ECharts into your project?

ES Module imports

Versions

echarts 5.3.3
vue 2.7.3
vue-echarts 6.2.2

Details

Should print log in console when hovering on chart, but nothing happens.

Reproduction

https://stackblitz.com/edit/vitejs-vite-kdw9ez

youthug commented 2 years ago

loading doesn't work either

youthug commented 2 years ago
<template>
  <v-chart ref="chart" />
</template>

<script lang="ts" setup>
  import { onBeforeUnmount, onMounted, ref } from 'vue'

  const chart = ref(null)

  const handleClick = () => {
    // do something
  }

  onMounted(() => {
    chart.value?.chart?.on('click', handleClick)
  })

  onBeforeUnmount(() => {
    chart.value?.chart?.off('click', handleClick)
  })
</script>

This works for me

Justineo commented 2 years ago

v-on should work now by upgrading to vue-echarts@6.2.3.

youthug commented 2 years ago

v-on should work now by upgrading to vue-echarts@6.2.3.

v-on worked! but loading seems still not working properly

Justineo commented 2 years ago

@youthug Please open a new issue with proper reproduction. Thank you!