33 lines
536 B
JavaScript
33 lines
536 B
JavaScript
export default {
|
|
name: 'toggler',
|
|
|
|
props: {
|
|
defaultVisible: {
|
|
type: Boolean,
|
|
default: () => false
|
|
}
|
|
},
|
|
|
|
data: function () {
|
|
return {
|
|
isVisible: this.defaultVisible
|
|
}
|
|
},
|
|
|
|
render: function (createElement) {
|
|
return createElement( this.$vnode.data.tag, [
|
|
this.$scopedSlots.default({
|
|
isVisible: this.isVisible,
|
|
toggle: this.toggle
|
|
})
|
|
])
|
|
},
|
|
|
|
methods: {
|
|
toggle: function (e) {
|
|
e.preventDefault()
|
|
this.isVisible = !this.isVisible
|
|
}
|
|
}
|
|
}
|