scroll-view scroll-x=“true”,当里面的子元素文本为英文或阿拉伯数字时,可以滚动,中文时无法滚动
代码如下:
<view class=“container”>
<scroll-view scroll-x=“true” class=“container-header”>
<block wx:for="{{headerNav}}" wx:key=“id”>
<view id=“item{{item.id}}” class=“scroll-view-item”>{{item.name}}</view></block>
</scroll-view>
</view>
//获取应用实例
var app = getApp()
Page({
data: {
motto: ‘Hello World’,
userInfo: {},
headerNav: [
{
“name”:“首页”,
“page”:"/pages/index/index",
“id”:1
},
{
“name”:“服饰鞋帽”,
“page”:"/pages/index/index",
“id”:2
},
{
“name”:“礼品箱包”,
“page”:"/pages/index/index",
“id”:3
},
{
“name”:“家居家装”,
“page”:"/pages/index/index",
“id”:4
},
{
“name”:“数码办公”,
“page”:"/pages/index/index",
“id”:5
},
{
“name”:“家用电器”,
“page”:"/pages/index/index",
“id”:6
},
{
“name”:“首页”,
“page”:"/pages/index/index",
“id”:7
},
]
}
})
page {
background-color: #F0F0F0;
height: 100%;
}
.container {
height: 100%;
display: flex;
flex-direction: column;
}
.container-header{
line-height:3rem;
height:3rem;
top:0;
z-index:9997;
background:#fff;
margin:0 auto !important;
}
.scroll-view-item{
display:inline;
height:3rem;
padding-left:40rpx;
}