Nativescrit TexField焦点

时间:2018-03-03 15:39:59

标签: nativescript

我正在努力使文本字段在被选中时位于键盘上方:

试过这段代码:

HTML:

<StackLayout class="input-field">
      <Label text="Postal Code" class="label font-weight-bold m-b-5"
      </Label>
     <TextField #postalCode id="postalCode" (tap)="onFocus()" 
     [(ngModel)]="model.address.postal_code" class="input" ></TextField>
</StackLayout>

TS:

onFocus() {
    let postalCode = <TextField> this.postalCode.nativeElement;
    console.log(postalCode.focus());
 }

1 个答案:

答案 0 :(得分:0)

如果您想在选择键盘时按下文本字段,请打开App_Resources/Android/AndroidManifest.xml并将其添加到<activityandroid:windowSoftInputMode="stateHidden|adjustResize"