fix theme tab, remove console.logs

This commit is contained in:
Henry Jameson 2021-04-18 15:03:28 +03:00
parent 433ea02a18
commit b0789fd6fd

View file

@ -36,17 +36,12 @@ export default {
} }
}, },
data () { data () {
console.log(this.$slots.default)
return { return {
// TODO VUE3: add () after 'default' // TODO VUE3: add () after 'default'
active: findFirstUsable(this.$slots.default) active: findFirstUsable(this.$slots.default)
} }
}, },
computed: { computed: {
slots () {
// TODO VUE3: add () at the end
return this.$slots.default
},
activeIndex () { activeIndex () {
// In case of controlled component // In case of controlled component
if (this.activeTab) { if (this.activeTab) {
@ -63,11 +58,10 @@ export default {
}) })
}, },
beforeUpdate () { beforeUpdate () {
console.log(this.slots, this.active) const currentSlot = this.slots()[this.active]
const currentSlot = this.slots[this.active]
// TODO VUE3: change data to props // TODO VUE3: change data to props
if (!currentSlot.data) { if (!currentSlot.data) {
this.active = findFirstUsable(this.slots) this.active = findFirstUsable(this.slots())
} }
}, },
methods: { methods: {
@ -77,9 +71,14 @@ export default {
this.setTab(index) this.setTab(index)
} }
}, },
// DO NOT put it to computed, it doesn't work (caching?)
slots () {
// TODO VUE3: add () at the end
return this.$slots.default
},
setTab (index) { setTab (index) {
if (typeof this.onSwitch === 'function') { if (typeof this.onSwitch === 'function') {
this.onSwitch.call(null, this.slots[index].key) this.onSwitch.call(null, this.slots()[index].key)
} }
this.active = index this.active = index
if (this.scrollableTabs) { if (this.scrollableTabs) {
@ -89,7 +88,7 @@ export default {
}, },
// TODO VUE3: remove 'h' here // TODO VUE3: remove 'h' here
render (h) { render (h) {
const tabs = this.slots const tabs = this.slots()
.map((slot, index) => { .map((slot, index) => {
// TODO VUE3 change to slot.props // TODO VUE3 change to slot.props
const props = slot.data && slot.data.attrs const props = slot.data && slot.data.attrs
@ -132,7 +131,7 @@ export default {
) )
}) })
const contents = this.slots.map((slot, index) => { const contents = this.slots().map((slot, index) => {
// TODO VUE3 change to slot.props // TODO VUE3 change to slot.props
const props = slot.data && slot.data.attrs const props = slot.data && slot.data.attrs
if (!props) return if (!props) return