ion-picker设定默认值

2019-08-06 14:48:50 浏览数 (2)

关于ion-picker的默认值设定,群里有人说找了几天没找到相关资料,不至于吧?

其实每列都有selectedIndex属性,设置下就好了:

代码语言:javascript复制
  async showBasicPicker() {
    const opts: PickerOptions = {
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel'
        },
        {
          text: 'Done'
        }
      ],
      columns: [
        {
          name: 'framework',
          selectedIndex: 2,
          options: [
            { text: 'Angular', value: 'A' },
            { text: 'Vue', value: 'B' },
            { text: 'React', value: 'C' }
          ]
        }
      ]
    };
    const picker = await this.pickerCtrl.create(opts);
    picker.present();
  }

image.png

0 人点赞