测试手机: 华为Mate9 Pro
<view>
<view class=‘main-title’>资讯</view>
<scroll-view class=“scroll-horizontal” scroll-x=“true” wx:for="{{newTitles}}" wx:key=“item”>
<view id=’{{item.colid}}’ class=‘nav-item’>{{item.colname}}</view>
</scroll-view>
</view>
.scroll-horizontal{
width: 100%;
height: 40px;
white-space: nowrap;
}
.nav-item{
width: 100px;
height: 40px;
line-height: 30px;
text-align: center;
display: inline-block;
background-color: #E2FCFE;
}
//获取应用实例
const app = getApp()
Page({
data: {
newTitles: [{ colname: ‘xx’, colid: 1 }, { colname: ‘tt’, colid: 2 }, { colname: ‘gg’, colid: 3 }]
}
})
为什么scroll-x无效,按官网文档上不加属性值true也试过,是无效的
<scroll-view class=“scroll-horizontal” scroll-x wx:for="{{newTitles}}" wx:key=“item”>
<view id=’{{item.colid}}’ class=‘nav-item’>{{item.colname}}</view>
</scroll-view>