标签样式style
:style="'width:' + getWidth('.pickTitle' + index) + 'px'">
事件:
getWidth(classId) {
const query = uni.createSelectorQuery().in(this)
query.select(classId).boundingClientRect(data => {
this.tabWidth[classId] = data.width / 2
}).exec();
return this.tabWidth[classId]
}
data值
tabWidth: {
pickTitle0: 0,
pickTitle1: 0,
pickTitle2: 0,
},
动态css:
:class="['pickTitle' + index, 'pick-up', picktab=== item.index ? 'pick-up2':'']"
v-for动态返回遍历的数组:
<view v-for="(item,index) in setPickList()" :key='index'>
// 根据类型获取tab
setPickList() {
let arr = []
if (this.detailInfo.applyType === 'sp') {
arr = this.pickTabList
} else {
arr = this.pickTabList.filter(item => item.index !== '1')
}
return arr
},
data中:过滤掉index为1的,v-for循环就循环最新和点赞数
pickTabList: [{
name: '投票数',
index: '1',
orderBy: 'rangk',
},
{
name: '最新',
index: '2',
orderBy: 'time',
},
{
name: '点赞数',
index: '3',
orderBy: 'like',
},
],