1.添加点击事件
<view @click="estimate">评价</view>
2.为将要跳转的位置添加id
<view class="pad-16" id="estimate" >
要跳的位置,也就是评价所在的模块。
</view>
3.编写点击事件
<script setup>
const estimate = ()=>{
document.getElementById("estimate").scrollIntoView({ behavior: 'smooth'});
}
</script>
uniapp更加直接
const scrollToTop = () => {
// window.scrollTo({
// // top: document.documentElement.offsetHeight, //回到底部
// top: 0, //回到顶部
// left: 0,
// behavior: "smooth", //smooth 平滑;auto:瞬间
// });
uni.pageScrollTo({
scrollTop: 0,
duration: 1000
});
};
// 跳转页面指定位置
const handlaos = ()=>{
uni.pageScrollTo({
selector: '.tea',//你要跳转的样式位置
duration: 300,//跳转时间段
})
}