From 0ddc49975510ddd633aa3232121be63ba4c0de7e Mon Sep 17 00:00:00 2001 From: Justineo Date: Tue, 12 Jul 2022 12:25:42 +0800 Subject: [PATCH] fix: v-on not working in 2.7 (fix #636) --- CHANGELOG.md | 4 ++++ README.md | 8 ++++---- README.zh-Hans.md | 8 ++++---- package.json | 2 +- src/ECharts.ts | 31 +++++++++++++++---------------- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e5f8c6..6bf2cbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.2.3 + +* Fixed the problem that `v-on` stops working after upgrading to `vue@2.7.x`. + ## 6.2.2 * Improve types for `update-options`. diff --git a/README.md b/README.md index a316f69..3d68699 100644 --- a/README.md +++ b/README.md @@ -304,13 +304,13 @@ export default { Drop ` - + ``` @@ -324,13 +324,13 @@ app.component('v-chart', VueECharts)
-Vue 2 Demo → +Vue 2 Demo → ```html - + ``` diff --git a/README.zh-Hans.md b/README.zh-Hans.md index cf62cbb..8c76aab 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -302,13 +302,13 @@ export default { 用如下方式在 HTML 中插入 ` - + ``` @@ -322,13 +322,13 @@ app.component('v-chart', VueECharts)
-Vue 2 Demo → +Vue 2 Demo → ```html - + ``` diff --git a/package.json b/package.json index 74cfd2f..b66aad5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-echarts", - "version": "6.2.2", + "version": "6.2.3", "description": "Vue.js component for Apache ECharts.", "author": "GU Yiling ", "scripts": { diff --git a/src/ECharts.ts b/src/ECharts.ts index e569229..8e88246 100644 --- a/src/ECharts.ts +++ b/src/ECharts.ts @@ -12,13 +12,14 @@ import { onUnmounted, h, nextTick, - PropType, watchEffect, + getCurrentInstance, Vue2, - InjectionKey + type PropType, + type InjectionKey } from "vue-demi"; import { init as initChart } from "echarts/core"; -import { +import type { EChartsType, EventTarget, Option, @@ -36,8 +37,8 @@ import { useLoading, loadingProps } from "./composables"; -import "./style.css"; import { omitOn } from "./utils"; +import "./style.css"; const TAG_NAME = "x-vue-echarts"; @@ -46,8 +47,10 @@ if (Vue2) { } export const THEME_KEY = "ecTheme" as unknown as InjectionKey; -export const INIT_OPTIONS_KEY = "ecInitOptions" as unknown as InjectionKey; -export const UPDATE_OPTIONS_KEY = "ecUpdateOptions" as unknown as InjectionKey; +export const INIT_OPTIONS_KEY = + "ecInitOptions" as unknown as InjectionKey; +export const UPDATE_OPTIONS_KEY = + "ecUpdateOptions" as unknown as InjectionKey; export { LOADING_OPTIONS_KEY } from "./composables"; export default defineComponent({ @@ -65,20 +68,13 @@ export default defineComponent({ ...loadingProps }, inheritAttrs: false, - // @ts-expect-error listeners for Vue 2 compatibility - setup(props, { attrs, listeners }) { + setup(props, { attrs }) { const root = shallowRef(); const chart = shallowRef(); const manualOption = shallowRef