*如果设置多级默认值可依次获取每一层级Picker对象并设置默认值,如下:
var picker = new mui.PopPicker({
layer: 2
});
picker.setData([{
value: '110000',
text: '北京市',
children: [{
value: "110101",
text: "东城区"
}]
}, {
value: '120000',
text: '天津市',
children: [{
value: "120101",
text: "和平区"
}, {
value: "120102",
text: "河东区"
}, {
value: "120104",
text: "南开区"
}
]
}])
picker.pickers[0].setSelectedIndex(1);
picker.pickers[1].setSelectedIndex(1);
picker.show(function(SelectedItem) {
console.log(SelectedItem);
})
[
setSelectedIndex(index[, duration, callback])
](#on-events-selector-data-handler)
参数:index
Type: Number;)
指定列表选中项
如:
picker.pickers[0].setSelectedIndex(4)
参数:duration
Type: Number;)
过渡效果持续时间(
ms
)如:
picker.pickers[0].setSelectedIndex(4,200)
参数:callback
Type: FUnction;)
设置成功回调
如:
picker.pickers[0].setSelectedIndex(4,200,function(){})
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.show(function(SelectedItem) {
console.log(SelectedItem);
})
[
setSelectedValue(value[, duration, callback])
](#on-events-selector-data-handler)
参数:value
Type: String;)
指定列表选中项
如:
picker.pickers[0].setSelectedValue('fourth')
参数:duration
Type: Number;)
渡效果持续时间(
ms
)如:
picker.pickers[0].setSelectedValue('fourth',200)
参数:callback
Type: FUnction;)
设置成功回调
如:
picker.pickers[0].setSelectedValue('fourth', 200, function(){})
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.show(function(SelectedItem) {
console.log(SelectedItem);
})
[
getSelectedItems()
](#on-events-selector-data-handler)
返回值[data]
Type: Array;)
获取选中的项(数组)
如:
picker.getSelectedItems()