最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

uni-app 滾動到指定位置的操作方法

 更新時間:2024年05月13日 15:03:23   作者:江-月*夜  
這篇文章主要介紹了uni-app 滾動到指定位置的操作方法,其中方法一是使用標簽,可以將頁面橫向(或縱向)滾動到指定位置還有其他多種方法,需要的朋友可以參考下

方法1:使用標簽,可以將頁面橫向(或縱向)滾動到指定位置
無法滾動 將代碼放在setTimeout,nextTick里執(zhí)行

<!-- 左邊 -->
			<scroll-view show-scrollbar="false" scroll-y="true" class="left-box"
				:scroll-top="scrollLeftTop" scroll-with-animation="true">
				<view class="scroll-view-item" v-for="(item,index) in servicesLeftList" :key="item.id"
					:id="'scroll' + activeLeftTab" :class="{'active':activeLeftTab==item.id}">
					{{item.name}}
				</view>
			</scroll-view>
data(){
return {
servicesLeftList:[],
scrollLeftTop:0,,//滾動位置
activeLeftTab:"" //選中的樣式
}
}
getData() {
	//接口
	getServicesTree().then(res => {
		this.servicesLeftList= res.data
		res.data.forEach((item, ind) => {
				setTimeout(()=>{
					uni.createSelectorQuery().in(this).select('#scroll' + item.id)
						.boundingClientRect(res => {
							scrollLeftTop.value = 65 * ind; // 設(shè)置滾動條距離左側(cè)的距離    				        
						}).exec()
				},100)
		})
	})
}

方法二 使用uni.pageScrollTo 使頁面縱向滾到到指定位置
建議設(shè)置height為auto :height:auto

<view class="left-box" >
				<view class="scroll-view-item" v-for="(item,index) in servicesLeftList" :key="item.id"
					 :class="{'active':activeLeftTab==item.id}">
					{{item.name}}
				</view>
			</view>
//方法
uni.pageScrollTo({
	scrollTop: 0,
	duration: 500
});

方法三 用scroll-view描點

 //左邊 :scroll-top="scrollLeftTop"
<scroll-view scroll-y="true" class="left-box" scroll-with-animation="true"
	:scroll-into-view="tracingLeftPoint">
	<view class="scroll-view-item" v-for="(item,index) in servicesLeftList" :key="item.id"
		:id="'scroll' + item.id" :class="{'active':activeLeftTab==item.id}">
		{{item.name}}
	</view>
</scroll-view>
//方法
data(){
	retrun {
		tracingLeftPoint:"",//描點id
	}
}
	getData() {
	//接口
		getServicesTree().then(res => {
			this.servicesLeftList= res.data
			res.data.forEach((item, ind) => {
					setTimeout(()=>{
						this.tracingLeftPoint= 'scroll' + item.id
					},200)
			})
		})
	}

到此這篇關(guān)于uni-app 滾動到指定位置的文章就介紹到這了,更多相關(guān)uni-app 滾動到指定位置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

五大连池市| 剑阁县| 湟中县| 郑州市| 湖北省| 遂川县| 新源县| 高唐县| 白河县| 巴中市| 满洲里市| 巴塘县| 宽甸| 伊川县| 旺苍县| 黄陵县| 葵青区| 浮山县| 洞头县| 康定县| 绵竹市| 甘南县| 赣榆县| 随州市| 江油市| 澄迈县| 延津县| 普陀区| 怀安县| 府谷县| 宁乡县| 永春县| 中牟县| 昌黎县| 文山县| 报价| 区。| 惠州市| 准格尔旗| 尼勒克县| 临湘市|