Commit fee8de57 authored by youjie's avatar youjie

no message

parent bc552add
......@@ -38,11 +38,11 @@
</style>
<template>
<view>
<scroll-view class="scheduleTsBox" :scroll-x="true"
:scrollLeft="scrollLeft">
<!-- :scroll-left="scrollLeft" -->
<scroll-view class="scheduleTsBox" :scroll-x="true">
<view class="scheduleT-text row-aic-n">
<template v-for="(item,index) in list">
<view class="scheduleText" :id="item.val"
<view class="scheduleText" :id="`refs_${index+1}`"
:class="[params.type==item.id?'active':'']"
:key="index"
@click="getType(item)">
......@@ -60,24 +60,52 @@
data(){
return {
list: [],
scrollLeft: ''
scrollLeft: 0
}
},
watch:{
titles: {
handler(newVal, oldVal) {
this.list = JSON.parse(JSON.stringify(newVal))
// 使用 $nextTick 等待 DOM 渲染完成
this.$nextTick(() => {
this.list.forEach((x, index) => {
// 查询当前元素的位置
uni.createSelectorQuery()
.in(this) // 限定在当前组件内查询(关键!)
.select(`#refs_${index + 1}`) // 匹配元素的 id
.fields({
position: true, // 获取位置信息(left/top)
size: true // 获取尺寸(width/height)
})
.exec((res) => {
if (res[0]) {
const { left, top, width, height } = res[0];
// console.log(`元素 ${index} 的横向位置(left):`, left); // 单位:px
// console.log(`元素 ${index} 的宽度:`, width);
x.left = width*(index)
} else {
console.log(`未找到元素 refs_${index + 1}`);
}
});
});
});
},
deep: true,
immediate: true
},
params: {
handler(newVal, oldVal) {
this.$nextTick(() => {
let findIndex = this.list.findIndex(x => x.id == newVal.type)
if(findIndex != -1) {
this.scrollLeft = this.list[findIndex].left
}
})
},
deep: true,
immediate: true
}
},
},
components: {
......
......@@ -116,26 +116,11 @@
</view>
</view>
<scheduleHeader :titles="titles" :params="params" @change="getType"></scheduleHeader>
<!--
<scroll-view class="scheduleTsBox" :scroll-x="true"
:scroll-left="scrollLeft"
@scroll="scrollHandler">
<view class="scheduleT-text row-aic-n">
<view class="scheduleText"
:class="[params.type==item.id?'active':'']"
v-for="(item,index) in titles"
:key="index"
@click="getType(item)">
<text>{{ item.name }}</text>
<view></view>
</view>
</view>
</scroll-view>-->
</view>
<view class="scheduleTitle fixed"
:style="{ opacity: boxOption + '%' ,'display':boxOption<=0?'none':'show'}">
<headers textAlign="left" :title="pageTitle" color="#fff"></headers>
<scheduleHeader :titles="titles" :params="params" @change="getType"></scheduleHeader>
<scheduleHeader v-if="boxOption>0" :titles="titles" :params="params" @change="getType"></scheduleHeader>
</view>
</view>
<infor1 v-if="params.type==1" :data="inforData1"></infor1>
......@@ -255,7 +240,7 @@ export default {
},
datas: {},
params:{
type: 1
type: 1,
},
scrollLeft: 0,
currencyList: [],
......@@ -309,7 +294,9 @@ export default {
this.optionObj = this.optionList[findIndex]
},
getType(item){
this.params.type = item.id
this.params = {
type: item.id,
}
},
init() {
uni.showLoading()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment