使用scroll-view组件的scroll-into-view实现。监听用户触摸状态判断上下。同理也可设计左右slide模式。
<template>
<view class="page">
<scroll-view scroll-y="true" :scroll-into-view="toView" class="scroll-view" :scroll-with-animation="true">
<view id="page1" @touchmove="switchPage"
@touchstart="startTouch" @touchend="endTouch">
page1
</view>
<view id="page2" @touchmove="switchPage"
@touchstart="startTouch" @touchend="endTouch">
page2
</view>
<view id="page3" @touchmove="switchPage"
@touchstart="startTouch" @touchend="endTouch">
page3
</view>
<view id="page4" @touchmove="switchPage"
@touchstart="startTouch" @touchend=