gpt4 book ai didi

html - Angular 通过按 Enter 键或单击按钮提交

转载 作者:行者123 更新时间:2023-12-02 03:08:47 24 4
gpt4 key购买 nike

我希望当我按回车键或登录按钮提交时。提交时只有单击按钮才起作用。谁能帮我让他们两个都工作吗?

<div class="BLog">
<div class="Log" (click)="Log()">
Log in
</div>
</div>
async Log() {
let self = this;
let ident = {
username: self.username,
password: self.password,
client_id: "task",
grant_type: "password",
}
let aux = await self.logService.postAt(ident);
if(aux) self.router.navigate(['first']);
}

最佳答案

您必须将其连接到表单中并添加一个提交类型的按钮

<form (submit)="Log()">
<div class="BLog">
<div class="Log">
<button type="submit">Log in</button>
</div>
</div>
</form>

关于html - Angular 通过按 Enter 键或单击按钮提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58260208/

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