首页 文章

Ionic3的键盘问题

提问于
浏览
0

我遇到键盘问题 . 我有一个包含5个输入字段的列表的页面 . 当键盘显示页面向上推,键盘隐藏页面位置时保持不变 . 当我检查它时,表明即使在键盘隐藏之后也存在 padding-bottom:300px . 有没有相同的解决方案?请在下面找到html代码

<ion-content padding #content>
<img src="assets/imgs/ic_tutorial_three.png" style="height:150px;width:150px">
<ion-card>
  <ion-item>
      <ion-avatar item-end class="margin-bottom-none" *ngIf="validCurrentKey">
          <img src="assets/imgs/ic_tick.png" class="tick-button">
        </ion-avatar>
    <ion-label color="primary" stacked>Your Current PIN</ion-label>
    <ion-input type="password" placeholder="PIN" (ionChange)='checkCurrentPassword($event)'></ion-input>
  </ion-item>
  <ion-item >
    <ion-label color="primary" stacked>Enter Your New PIN</ion-label>
    <ion-input type="password" placeholder="PIN"  [(ngModel)]="newPin"></ion-input>
  </ion-item>
  <ion-item>
    <ion-label color="primary" stacked>RE-Enter Your New PIN</ion-label>
    <ion-input type="password" placeholder="PIN"  (ionChange)="validateNewPassword($event)"></ion-input>
  </ion-item>
</ion-card>
<div class="bottom-button"> 
    <button ion-button round full class="submit-button"  (click)="goBack()" >UPDATE PIN</button>
</div>

我对这个问题有同样的问题ionic 3 -Keyboard pushes the whole screen up

1 回答

  • 0

    出现此问题的原因是输入字段获得焦点时滚动 .

    要在聚焦输入时禁用滚动,请将以下代码添加到项目的“app.module.ts”文件中:

    imports: [
        IonicModule.forRoot(MyApp, {
            scrollPadding: false,
            scrollAssist: false, 
            autoFocusAssist: false
        }),
        ...
    ],
    

    另请查看以下链接以获取详细说明:https://stackoverflow.com/a/41163695/6862286

相关问题