簡體   English   中英

禁用警報控制器 ionic 3 的輸入字段的自動對焦

[英]Disable auto-focus on input field for alert controller ionic 3

如何使用警報控制器禁用創建的警報,使其在顯示鍵盤的情況下自動聚焦到輸入字段?

let alert = self.alertCtrl.create({
        title: 'Login',
        inputs: [
          {
            name: 'location_code',
            placeholder: 'Location Code',
          },
          {
            name: 'password',
            placeholder: 'Password',
            type: 'password'
          }
        ],
        buttons: [
          {
            text: 'Cancel',
            role: 'cancel',
            handler: data => {
              console.log('Cancel clicked');
            }
          },
          {
            text: 'Login',
            handler: data => {
                 console.log("Handling Login On Click")
              });
            }
          }
        ]
      });
      alert.present();

沒有導致任何變化的嘗試解決方案

this.alertController.create(
...
)
.present({
    keyboardClose: true
});

在 ionic 3 中沒有keyboardClose選項(參見v3 vs v5 ),因此您可能需要手動移除焦點,例如:

let alert = self.alertCtrl.create({...});
alert.present().then(() => {
  (<any>document.querySelector('ion-alert input')).blur();
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM