wxml:
<view class="bottom-kuangjia">
<picker class="p" bindchange="bindPickerChange" value="{{index}}" range="{{array}}" custom-item="请选择">
<view class='classify-kuangjia'>
<view>商品分类选择:</view>
<view class="picker">{{array[index]}}</view>
</view>
</picker>
</view>
wxss:
/* miniprogram/pages/QQ/QQ.wxss */
.bottom-kuangjia{
width: 100%;
height: 60rpx;
background-color: rgba(231, 229, 229, 0.502);
}
.classify-kuangjia{
width: 90%;
margin-left: 5%;
margin-right: 5%;
height: 60rpx;
display: flex;
justify-content: space-around;
background-color: forestgreen;
}
.picker{
text-align: center;
background-color: red;
width: 50%;
height: 60rpx;
}
js:
Page({
/**
* 页面的初始数据
*/
data: {
array: ['请选择', '手机', '电脑', '办公用品', '生活用品', '其他'],
index: 0,
},
//分类选择
bindPickerChange: function (e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
index: e.detail.value
})
},
})
效果图: