Skip to content

Commit c83de6d

Browse files
committed
fix: vue3 rough-notation render error
1 parent c3d0ca9 commit c83de6d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/components/RoughNotation.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,22 @@ export default (options) =>
158158
},
159159

160160
render(h2) {
161-
const slot =
162-
typeof this.$slots.default === 'function'
163-
? this.$slots.default()
164-
: this.$slots.default;
161+
// vue2
162+
if (h2 && typeof h2 === 'function') {
163+
const slot = this.$slots.default;
164+
165+
if (this.tag) {
166+
return h2(this.tag, null, slot);
167+
}
168+
169+
return slot && slot[0];
170+
}
171+
172+
// vue3
173+
const slot = this.$slots.default();
165174

166175
if (this.tag) {
167-
return h2(this.tag, null, slot);
176+
return h(this.tag, null, slot);
168177
}
169178

170179
return slot && slot[0];

src/components/RoughNotationGroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export default defineComponent({
110110
const slot = this.$slots.default;
111111

112112
if (this.tag) {
113-
return h2(this.tag, {}, slot);
113+
return h2(this.tag, null, slot);
114114
}
115115

116116
return slot && slot[0];

0 commit comments

Comments
 (0)