gpt4 book ai didi

Angular2/Nativescript : Submit a form when return key is pressed on soft keyboard

转载 作者:行者123 更新时间:2023-12-04 12:47:38 26 4
gpt4 key购买 nike

我有一个带有用户名和密码 TextFields 的 Angular2/Nativescript 登录组件...在编辑密码 textField 时,我将 returnKeyType 设置为“done”,并期望在按下 Done 时调用 login() 函数软键盘。在按下完成的那一刻,键盘被关闭但登录功能没有被调用所以我仍然必须在键盘关闭后点击登录按钮才能提交表单。当在 Nativescript 中的特定 TextField 上按下返回键时,有什么方法可以提交表单吗?如果是这样,我该如何着手实现它?我尝试了 returnPress 事件,但没有任何反应......

我的代码:

<ActionBar title="Login"></ActionBar>
<StackLayout class="page">
<GridLayout columns="*, auto" rows="auto">
<ActivityIndicator class="m-l-10 m-t-10 activity-indicator" [busy]="busy" [visibility]="busy ? 'visible' : 'collapse'" horizontalAlignment="left"></ActivityIndicator>
<Button row="0" col="1" id="setIPBtn" class=" m-t-20 pull-right font-awesome" text="&#xf0ad; Settings" (tap)="setIP()"></Button>
</GridLayout>

<Label class="m-x-auto m-t-20 title h1 text-primary p-x-10" text="Log In" backgroundColor="blue"></Label>
<StackLayout class="form">
<StackLayout class="input-field">
<Label class="body label text-left" text="Enter Username"></Label>
<TextField class="input input-border" hint="Username" [(ngModel)]="username" autocorrect="false" autocapitalizationType="none" returnKeyType="next"></TextField>
</StackLayout>
<StackLayout class="input-field">
<Label class="body label text-left" text="Enter Username"></Label>
<TextField class="input input-border" secure="true" hint="Password" [(ngModel)]="password" autocorrect="false" autocapitalizationType="none" returnKeyType="done" returnPress="login()"></TextField>
</StackLayout>
<Button class="btn btn-submit font-awesome bg-primary" [text]="isLoggingIn ? 'Logging in...' : '&#xf090; Login'" (tap)="login()" [isEnabled]="username !== '' && username !== null && password !== '' && password !== null && !isLoggingIn"></Button>
</StackLayout>



</StackLayout>

最佳答案

试试这个:

(returnPress)="login()"

关于Angular2/Nativescript : Submit a form when return key is pressed on soft keyboard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43200847/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com