buefy
Version:
Lightweight UI components for Vue.js based on Bulma
53 lines (51 loc) • 1.13 kB
JavaScript
var SlotComponent = {
name: 'BSlotComponent',
props: {
component: {
type: Object,
required: true
},
name: {
type: String,
default: 'default'
},
scoped: {
type: Boolean
},
props: {
type: Object
},
tag: {
type: String,
default: 'div'
},
event: {
type: String,
default: 'hook:updated'
}
},
methods: {
refresh: function refresh() {
this.$forceUpdate();
},
isVueComponent: function isVueComponent() {
return this.component && this.component._isVue;
}
},
created: function created() {
if (this.isVueComponent()) {
this.component.$on(this.event, this.refresh);
}
},
beforeDestroy: function beforeDestroy() {
if (this.isVueComponent()) {
this.component.$off(this.event, this.refresh);
}
},
render: function render(createElement) {
if (this.isVueComponent()) {
return createElement(this.tag, {}, this.scoped ? this.component.$scopedSlots[this.name](this.props) : this.component.$slots[this.name]);
}
}
};
export { SlotComponent as S };