Skip to content

Commit a23e36d

Browse files
author
savoygu
committed
fixed: when no title specified, sub title component always render
1 parent ff9f16c commit a23e36d

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

lib/vue-demonstration.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Demo.vue

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,27 @@
118118
hasSlot: Boolean
119119
},
120120
render (h) {
121-
return h(this.tag, {
122-
attrs: {
123-
id: this.anchor
124-
}
125-
},
126-
[
127-
h('a', {
121+
if (this.title || this.hasSlot) {
122+
return h(this.tag, {
128123
attrs: {
129-
href: '#' + this.anchor,
130-
'aria-hidden': true,
131-
class: 'header-anchor'
132-
},
133-
domProps: {
134-
innerHTML: ''
124+
id: this.anchor
135125
}
136-
}),
137-
this.title ? this.title : (this.hasSlot ? this.$parent.$slots.title : '' )
138-
])
126+
},
127+
[
128+
h('a', {
129+
attrs: {
130+
href: '#' + this.anchor,
131+
'aria-hidden': true,
132+
class: 'header-anchor'
133+
},
134+
domProps: {
135+
innerHTML: ''
136+
}
137+
}),
138+
this.title ? this.title : this.$parent.$slots.title
139+
])
140+
}
141+
return ''
139142
}
140143
},
141144
'vd-demo-description': {
@@ -160,6 +163,7 @@
160163
}
161164
}, this.$parent.$slots.description)
162165
}
166+
return ''
163167
}
164168
}
165169
}

0 commit comments

Comments
 (0)