选择器里面有中国、美国、巴西3项,我想实现每选择一项,view就会出现对应的拼音字母。可是我怎么弄都对不上号。哪位大神帮忙看下是怎么回事?
源码:
wxml:
<view space="emsp"class=“myText”> 拼音字母{{ checkArr}}</view>
<picker bindchange=“bindPickerChange” value="{{index}}" range="{{array}}">
<view class=“weui-input”>{{array[index]}}</view>
</picker>
js:
Page({
data: {
array: [‘中国’, ‘美国’, ‘巴西’],
index: 0,
checkArr: [’’]
},
bindPickerChange: function(e) {
this.setData({ index: e.detail.value });
if (e.detail.value = 0) {
this.setData({ checkArr: “zhongguo” });
}else if (e.detail.value = 1) {
this.setData({ checkArr: “meiguo” });}
else {this.setData({ checkArr: “baxi” });}}
})