ionic4+

ion-picker设定默认值

2019-08-02  本文已影响5人  IT晴天

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

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

  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
上一篇下一篇

猜你喜欢

热点阅读