老师,tab不显示内容,帮忙排查一下可以吗
来源:4-1 tab 组件基础实现

慕粉1230329569
2020-03-10
<template>
<div class="tab">
<cube-tab-bar
:useTransition=false
:showSlider=true
v-model="selectedLabel"
:data="tabs"
ref="tabBar"
class="border-bottom-1px"
>
</cube-tab-bar>
<div class="slide-wrapper">
<cube-slide
:loop=false
:auto-play=false
:show-dots=false
:initial-index="index"
ref="slide"
>
<cube-slide-item>
11111111
</cube-slide-item>
<cube-slide-item>
22222222
</cube-slide-item>
<cube-slide-item>
22222222222
</cube-slide-item>
</cube-slide>
</div>
</div>
</template>
<script>
export default {
name: 'tab',
props: {
initialIndex: {
type: Number,
default: 0
}
},
data() {
return {
index: this.initialIndex,
tabs: [{
label: '全部'
}, {
label: '成功'
}, {
label: '查询中'
}
],
slideOptions: {
listenScroll: true,
probeType: 3,
directionLockThreshold: 0
}
}
},
computed: {
selectedLabel: {
get() {
return this.tabs[this.index].label
},
set(newVal) {
this.index = this.tabs.findIndex((value) => {
return value.label === newVal
})
}
}
},
methods: {
onScroll(pos) {
const tabBarWidth = this.$refs.tabBar.$el.clientWidth
const slideWidth = this.$refs.slide.slide.scrollerWidth
const transform = -pos.x / slideWidth * tabBarWidth
this.$refs.tabBar.setSliderTransform(transform)
},
onChange(current) {
this.index = current
console.log(this.index)
const instance = this.$refs.component[current]
if (instance && instance.fetch) {
instance.fetch()
}
}
}
}
</script>
<style lang="stylus" scoped>
@import "~common/stylus/variable"
.tab
display: flex
flex-direction: column
height: 100%
>>> .cube-tab
padding: 10px 0
.slide-wrapper
flex: 1
overflow: hidden
</style>
写回答
4回答
-
这里改成 v-if 就可以了022020-03-11 -
ustbhuangyi
2020-03-10
你上传的代码以及分支对吗,我怎么打开是这样的?012020-03-10 -
ustbhuangyi
2020-03-10
你把代码传到 GitHub 上,我抽空帮你看下
012020-03-10 -
ustbhuangyi
2020-03-10
看一下对应的 DOM 有没有渲染出来。
012020-03-10
相似问题