<div class="tab" ref="tab">
<div class="tab_content">
<div class="tab_item" v-for="(item,index) in menuList" :key="index">
{{item.name}}
</div>
</div>
</div>
props: {
// 首页传过来的tab的值
menuList:null,
},
methods: {
onScroll(){
this.$nextTick(()=>{
if (!this.scroll) {
this.scroll=new BScroll(this.$refs.tab, {
startX:0,
click:true,
scrollX:true,
scrollY:false,
})
}else{
this.scroll.refresh()
}
})
}
},
mounted () {
this.onScroll()
}
<style>
.tab{
width: 7.54rem;
height: 0.88rem;
background: #fff;
overflow: hidden;
}
.tab_item{
display: inline-block;
height: 0.88rem;
line-height: 0.888rem;
padding: 0 0.466667rem;
}
</style>