请选择 进入手机版 | 继续访问电脑版
帖子
帖子
用户
博客
课程
显示全部楼层
134
帖子
2
勋章
902
Y币

[多端开发] scroll-view的scroll-into-view 只设置一个id就行了么

[复制链接]
发表于 2022-1-8 16:59:07
scroll-view的scroll-into-view 只设置一个id就行了么 , 还需要设置别的属性么
<scroll-view class="main" scroll-y scroll-with-animation="{{true}}" scroll-into-view={{id}}> <view class="flex" id="j"></scroll-view>
点击按钮后将scroll-into-view的id, 赋值成j 并没有滑动的效果
380
帖子
4
勋章
6
Y币
我们测试看看
380
帖子
4
勋章
6
Y币
  1. <template>
  2.         <view>
  3.                 <text class="title">水平滚动</text>
  4.                 <scroll-view class="scroll-view" scroll-x scroll-y="false">
  5.                         <view class="item red"></view>
  6.                         <view class="item green"></view>
  7.                         <view class="item blue"></view>
  8.                 </scroll-view>
  9.                 <text class="title">垂直滚动</text>
  10.                 <scroll-view scroll-into-view={{id}} class="scroll-view" scroll-y>
  11.                         <view  class="item red"></view>
  12.                         <view id="green" onclick='fntest' class="item green"></view>
  13.                         <view id="blue" class="item blue"></view>
  14.                 </scroll-view>
  15.         </view>
  16. </template>
  17. <style>
  18. .scroll-view {
  19.         width: 100%;
  20.         height: 150px;
  21. }
  22. .title {
  23.         padding: 10px 0;
  24.         font-size: 20px;
  25. }
  26. .item {
  27.         width: 100%;
  28.         height: 100%;
  29. }
  30. .red {
  31.         background-color: #f00;
  32. }
  33. .green {
  34.         background-color: #0f0;
  35. }
  36. .blue {
  37.         background-color: #00f;
  38. }
  39. </style>
  40. <script>
  41. export default {
  42.         name: 'test',
  43.         data() {
  44.                 return {
  45.                         id: 'green',
  46.                 }
  47.         },
  48.         method: {
  49.                 fntest(){
  50.                    this.data.id = 'blue'
  51.                 }

  52.         }
  53. }
  54. </script>
复制代码


测试可以的
134
帖子
2
勋章
902
Y币
好的, 我在试试
您需要登录后才可以回帖 登录

本版积分规则