Vue.component('anchored-heading', {
render: function(createElement) {
var _self = this;
return createElement(
'h' + this.level, {
on: {
click: this.hclick
}
}, [this.$slots.default, (function() {
if(_self.level === 1) {
return createElement('div', 'h1大标签')
}else{
return createElement('div', 'h2中标签')
}
})()]
)
},
methods: {
hclick() {
alert(123);
}
},
props: {
level: {
type: Number,
required: true
}
}
})
不知道有没有更好的办法
所有评论(0)