设置默认值
PopPicker
创建实例并填充数据后,可以设定每个层级的选中项,因为 PopPicker 是支持多层级联的,所以,可通过 instance.pickers[index]
拿到指定层级的实例,然后通过setSelectedIndex()
和setSelectedValue()
两个方法,设定指定层级的选中项,如下代码供参考:
var picker = new mui.PopPicker();
picker.setData([{
value: "first",
text: "第一项"
}, {
value: "second",
text: "第一项"
}, {
value: "third",
text: "第三项"
}, {
value: "fourth",
text: "第四项"
}, {
value: "fifth",
text: "第五项"
}])
//picker.pickers[0].setSelectedIndex(4, 2000);
picker.pickers[0].setSelectedValue('fourth', 2000);
picker.show(function(SelectedItem) {
console.log(SelectedItem);
})