选项卡的实现
<view v-for=”(item,index) in list” :key=”index” class=”class1”
:class=”{active:activeIndex===index}” @click=”clickTab(item,index)”>{{item.name}}</view>
props:{
list:{
type:Array,
default(){
return []
}
}
}
data(){
return{
//list:[“选项一”,“选项二”,“选项三”,“选项四”,],
activeIndex:0
}
},
methods:{
clickTab(item,index){
this.activeIndex=index
this.$emit(‘tab’,{
data:item,
index:index
})
}
}
}
父组件<tab :list=”tablist” @tab=”tab”></tab>
tab({data,index}){
console.log(data,index)
}
不fixed 实现滚动scroll-view
<view class="home">
<view>不fixed也能固定住</view>
<view class="scroll">
<scroll-view scroll-y>
<view><view v-for=”item in 100”>{{item}}</view></view>
</scroll-view>
</view>
</view>
page{
height:100%;
display:flex;
}
.home{
display:flex;
flex-direction:column;
flex:1;
}
.scroll{
flex:1;
overflow:hidden;
box-sizing:border-box;
}
scroll-view{
height:100%;
display:flex;
flex-direction:column;
}
文字溢出隐藏
text{
overflow:hidden;
text-overflow:ellipsis;
display:-webkit-box;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
}