Files
FirstUI-vue/components/firstui/fui-vtabs-content/fui-vtabs-content.vue
2023-08-17 21:28:49 +08:00

96 lines
2.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--本文件由FirstUI授权予新疆天衡创新研究院有限公司手机号1 8614 0 72 5 4 9身份证尾号5A07X5专用请尊重知识产权勿私下传播违者追究法律责任-->
<template>
<view class="fui-vtabs-content__wrap" ref="fui_vtabs__el" :id="'fui-vtabs-content__'+tabIndex">
<slot></slot>
</view>
</template>
<script>
// #ifdef APP-NVUE
const dom = weex.requireModule('dom')
// #endif
export default {
name: "fui-vtabs-content",
inject: ['vtabs'],
props: {
tabIndex: {
type: [Number, String],
default: 0
}
},
mounted() {
if (this.vtabs && this.vtabs.linkage) {
this.vtabs.children.push(this)
this.$nextTick(()=>{
setTimeout(() => {
this.calcHeight((height) => {
this.vtabs.getCalcHeight(height, Number(this.tabIndex))
})
}, 300)
})
}
},
// #ifndef VUE3
// TODO vue2
beforeDestroy() {
this.uninstall()
},
// #endif
// #ifdef VUE3
// TODO vue3
beforeUnmount() {
this.uninstall()
},
// #endif
methods: {
calcHeight(callback, index = 0) {
// #ifdef APP-NVUE
const result = dom.getComponentRect(this.$refs['fui_vtabs__el'], option => {
if (option && option.result && option.size) {
callback && callback(option.size.height + 1)
}
})
// #endif
// #ifndef APP-NVUE
uni.createSelectorQuery()
// #ifndef MP-ALIPAY
.in(this)
// #endif
.select(`#fui-vtabs-content__${this.tabIndex}`)
.fields({
size: true
}, data => {
if (index >= 12) return
if (data && data.height) {
callback && callback(data.height)
} else {
index++
setTimeout(() => {
this.calcHeight(callback, index)
}, 50)
return
}
})
.exec()
// #endif
},
uninstall() {
if (this.vtabs && this.vtabs.linkage) {
this.vtabs.uninstall(Number(this.tabIndex),this)
}
}
}
}
</script>
<style scoped>
.fui-vtabs-content__wrap {
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
/* #ifndef APP-NVUE */
width: 100%;
/* #endif */
}
</style>