fix: attributes should fall onto the root for Vue 2 (#670)

This commit is contained in:
Justineo
2022-12-07 19:44:29 +08:00
parent e44c9dfd40
commit 6304a1b15a

View File

@ -281,7 +281,11 @@ export default defineComponent({
};
},
render() {
const attrs = { ...this.nonEventAttrs };
// Vue 3 and Vue 2 have different vnode props format:
// See https://v3-migration.vuejs.org/breaking-changes/render-function-api.html#vnode-props-format
const attrs = (
Vue2 ? { attrs: this.nonEventAttrs } : { ...this.nonEventAttrs }
) as any;
attrs.ref = "root";
attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts";
return h(TAG_NAME, attrs);