1.绑定类名
<view class="list-wrapper"> <view class="list-top"> <view data-num="1" class="list-menu list-menu1 {{_num==1?\'cur\':\'\'}}" bindtap="menuClick">头条</view> <view data-num="2" class="list-menu list-menu2 {{_num==2?\'cur\':\'\'}}" bindtap="menuClick">活动</view> <view data-num="3" class="list-menu list-menu3 {{_num==3?\'cur\':\'\'}}" bindtap="menuClick">公告</view> </view> </view>
2.绑定输入框
(1)输入框 <input type=\'text\' bindchange=\'changInput\' data-id="1" placeholder=\'邮政编码\'></input> (2)下拉选择时间 <picker bindchange="changInput" mode="date" value="{{postData.mail_time}}" start="2019-06-01" end="2020-09-01"> <view class="picker"> {{postData.mail_time}} </view> </picker> (3)下拉选择单项 <picker bindchange="changInput" data-id="6" value="{{indexPerson}}" range="{{arrayPerson}}"> <view class="picker"> {{arrayPerson[indexPerson]||\'请选择人数\'}} </view> </picker> 当输入框变化时,方法changInput就了根据传过来的id来判断处理值 <script> changInput(e) { let id = e.currentTarget.dataset.id let value = e.detail.value if (id === 1) { this.setData({ value: value }) } } </script>
3.数据遍历
<view wx:key="{{item}}" wx:for="{{pingData}}"> {{item.user.nickname}} </view>
请发表评论