js:
data: { array:['请选择','父母','子女','配偶']},
bindPickerChange2: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
index2: e.detail.value
})
},
wxml:
<picker bindchange="bindPickerChange2" value="{{index3}}" range="{{array2}}">
<view class="picker" >
证件类型:{{array2[index2]}}
</view>
</picker>
如何在一打开界面在 证件类型 后面 自动显示灰色“请选择” ,在点击picker后改变“请选择”的文本内容
js
Page({
data: {
array: ['美国', '中国', '巴西', '日本'],
index: 0,
default: '请选择',
},
bindPickerChange: function (e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
let index = e.detail.value
let array = this.data.array
this.setData({
index,
default: array[index]
})
},
wxml
<view class="section">
<view class="section__title">普通选择器</view>
<picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}">
<view class="picker">
当前选择:{{default}}
</view>
</picker>
</view>