Vue3 设置点击后滚动条移动到固定的位置

需求:
点击不通过按钮,显示红框中表单,且滚动条滚动到底部 (显示红框中表单默认不显示)
在这里插入图片描述

<el-button @click="onApprovalPass">不通过</el-button>
<div class="item" v-if="approvalPassShow">
      红框中表单内容缩减版
</div>
<div  ref="footerListRef">
    <el-button type="primary" >提交</el-button>
    //滚动条移动到这个位置
</div>
<script setup>
const approvalPassShow = ref(false)
const footerListRef = ref(null);
const onApprovalPass = () => {
    
    
  approvalPassShow.value = true
  setTimeout(() => {
    
    
  // 移动滚动条
    footerListRef.value.scrollIntoView({
    
     block: "start", behavior: "smooth" });
  }, 50);
};
</script>

猜你喜欢

转载自blog.csdn.net/weixin_55042716/article/details/134604257
今日推荐