微信小程序中文本滚动的两种方式

可以使用textarea和text两种,

将这两种控件放入View中,设置height值,必须设置值,不要写100%,这样没用的。然后根据需求开始滚动即可。

控件配置如下:

     
       class="th-text" disabled='true'  style="overflow-y:auto;overflow-x:scroll;" selectable="true">{{item.text}}
 


class的th-text中的设置如下:

.th-text {
  width: 100%;
  justify-content: center;
  color: #000;
  display: block;
  height: 70rpx;
  align-items: center;
  max-height: 70rpx;
}


红色部分就是必须要设置的。但是我在实际运用中发现textarea在开发环境中好用,但手机中不好用。所以选择的text.

    

你可能感兴趣的:(JS+微信小程序)