【发布时间】:2020-05-17 19:23:01
【问题描述】:
我遇到的一个问题是,当我在 android 上导航到包含表单的页面时,键盘会自动弹出。我找到了一个解决方案,但它只适用于 Android:
import { View } from "tns-core-modules/ui/core/view";
export class AutoFocusView extends View {
createNativeView() {
if (typeof android !== "undefined") {
const linearLayout = new android.widget.LinearLayout(this._context);
linearLayout.setFocusableInTouchMode(true);
linearLayout.setFocusable(true);
return linearLayout;
}
return super.createNativeView();
}
onLoaded() {
super.onLoaded();
this.requestFocus();
}
requestFocus() {
const nativeViewProtected = this.nativeViewProtected;
nativeViewProtected.requestFocus();
}
}
我使用这个组件。但它只适用于android,所以每次我想为IOS构建时,我都需要从我的代码中评论它。我想知道是否有更简单的方法。
【问题讨论】:
标签: android ios nativescript nativescript-vue