mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-08-15 03:33:19 +08:00
fix: move events collecting from init to setup
This commit is contained in:
@ -101,22 +101,6 @@ export default defineComponent({
|
||||
|
||||
// @ts-expect-error listeners for Vue 2 compatibility
|
||||
const listeners = getCurrentInstance().proxy.$listeners;
|
||||
|
||||
function init(option?: Option) {
|
||||
if (!inner.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const instance = (chart.value = initChart(
|
||||
inner.value,
|
||||
realTheme.value,
|
||||
realInitOptions.value
|
||||
));
|
||||
|
||||
if (props.group) {
|
||||
instance.group = props.group;
|
||||
}
|
||||
|
||||
const realListeners: Record<string, any> = {};
|
||||
|
||||
if (!listeners) {
|
||||
@ -136,9 +120,9 @@ export default defineComponent({
|
||||
// Collect native DOM events
|
||||
if (event.indexOf("native:") === 0) {
|
||||
// native:click -> onClick
|
||||
const nativeKey = `on${event
|
||||
.charAt(7)
|
||||
.toUpperCase()}${event.slice(8)}`;
|
||||
const nativeKey = `on${event.charAt(7).toUpperCase()}${event.slice(
|
||||
8
|
||||
)}`;
|
||||
|
||||
nativeListeners[nativeKey] = attrs[key];
|
||||
return;
|
||||
@ -163,14 +147,28 @@ export default defineComponent({
|
||||
// &~!native:click -> &~!click
|
||||
Object.keys(listeners).forEach(key => {
|
||||
if (NATIVE_EVENT_RE.test(key)) {
|
||||
nativeListeners[key.replace(NATIVE_EVENT_RE, "$1")] =
|
||||
listeners[key];
|
||||
nativeListeners[key.replace(NATIVE_EVENT_RE, "$1")] = listeners[key];
|
||||
} else {
|
||||
realListeners[key] = listeners[key];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init(option?: Option) {
|
||||
if (!inner.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const instance = (chart.value = initChart(
|
||||
inner.value,
|
||||
realTheme.value,
|
||||
realInitOptions.value
|
||||
));
|
||||
|
||||
if (props.group) {
|
||||
instance.group = props.group;
|
||||
}
|
||||
|
||||
Object.keys(realListeners).forEach(key => {
|
||||
let handler = realListeners[key];
|
||||
|
||||
|
Reference in New Issue
Block a user