After taking it for a whole afternoon, this component is really a hell component
There are two solutions, one is the solution in vue2 and vue3
Let's talk about vue2 first
<van-tabs ref="tabs" id="tabs" :active="active" @change="onChange" ></van-tabs>
Bind ref on this
created() {
setTimeout(() => {
this.$refs.tabs.resize()
}, 500)
},
Then talk about vue3 syntax
<van-tabs ref="tabs" id="tabs" :active="active" @change="onChange" >
The id is used here to obtain resize() to trigger redrawing
export default {
import {onMounted,reactive,toRefs,getCurrentInstance,ref} from 'vue'
setup(){
let ins = getCurrentInstance();
onMounted(()=>{
setTimeout(()=>{
ins.ctx.selectComponent("#tabs").resize()
},200);
})
return{
}
}
}