小程序省市三级联动 及日期选择 (年月日)
作者:互联网
日期选择
<picker class="date=='选择生日'?'placeName':'placeText'" mode="date" value="{{date}}" start="2015-09-01" end="{{dateEnd}}" bindchange="bindDateChange"> <view class="picker"> {{date}} </view> </picker>
js
data数据有 date: '选择生日', dateEnd:'2021-07-09' bindDateChange: function(e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ date: e.detail.value }) this.saveInfor(1) },
小程序省市三级联动
<picker class="picker-box" mode="region" bindchange="bindRegionChange" value="{{detailed}}" custom-item="{{customItem}}" name="detailed" > <view class="picker {{clas}}" >{{detailed}}</view> </picker>
js
data有 customItem: [], detailed: '请选择', //省市联动 bindRegionChange: function (e) { var that = this //为了让选择框有个默认值, that.setData({ clas: '' }) //下拉框所选择的值 console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ //拼的字符串传后台 detailed: e.detail.value[0] + " " + e.detail.value[1] + " " + e.detail.value[2], //下拉框选中的值 region: e.detail.value }) this.setData({ "AddSite.area": e.detail.value[0] + " " + e.detail.value[1] + " " + e.detail.value[2], province:e.detail.value[0], city:e.detail.value[1], district:e.detail.value[2], }) this.saveInfor(2) console.log(this.data.AddSite) },
标签:detailed,省市,console,detail,value,选择,联动,年月日,setData 来源: https://www.cnblogs.com/shuihanxiao/p/15048337.html