设置默认值

PopPicker 创建实例并填充数据后,可以设定每个层级的选中项,因为 PopPicker 是支持多层级联的,所以,可通过 instance.pickers[index] 拿到指定层级的实例,然后通过setSelectedIndex()setSelectedValue()两个方法,设定指定层级的选中项,如下代码供参考:

  1. var picker = new mui.PopPicker();
  2. picker.setData([{
  3. value: "first",
  4. text: "第一项"
  5. }, {
  6. value: "second",
  7. text: "第一项"
  8. }, {
  9. value: "third",
  10. text: "第三项"
  11. }, {
  12. value: "fourth",
  13. text: "第四项"
  14. }, {
  15. value: "fifth",
  16. text: "第五项"
  17. }])
  18. //picker.pickers[0].setSelectedIndex(4, 2000);
  19. picker.pickers[0].setSelectedValue('fourth', 2000);
  20. picker.show(function(SelectedItem) {
  21. console.log(SelectedItem);
  22. })