picker选择器onConfirm无法获取选中的值
zeronehost opened this issue · 0 comments
zeronehost commented
直接下载代码将dist目录复制到项目中
代码如下:
index.axml
<view>
<van-cell title="银行" is-link value="{{list[model].label}}" onClick="show"/>
<van-popup show="{{show}}" position="bottom" onClose="select_close">
<van-picker title="银行" show-toolbar columns="{{list}}" value-key="label" onCancel="select_cancel" onConfirm="select_confirm"/>
</van-popup>
</view>
index.js
Page({
data: {
list: [{
brief: "选项一说明",
label: "选项一",
value: "1"
}, {
brief: "选项二说明",
label: "选项二",
value: "2"
}],
model: 0,
show: false
},
select_show() {
this.setData({
show: true
});
},
select_close() {
this.setData({
show: false
});
},
select_cancel() {
this.select_close();
},
select_confirm(e) {
this.select_close();
this.setData({
model: e.detail.index
});
}
});