Angular-为什么key.enter在mat -menu内部不起作用

发布于 2025-02-09 19:18:12 字数 321 浏览 0 评论 0 原文

之后,我想发射活动

  <input
    matInput
    type="number"
    min="0"
    placeholder="0"
    (keyup.enter)="minValue($event)"
  />

我有以下输入,按下Enter:我也尝试过(keydown.enter)=“ minvalue($ event)” 。 用户如何键入一个值以及按Enter在Entry时如何调用MinValue方法?

另外,当我单击输入字段以键入一个值时,输入框在写任何内容之前就消失了。

多谢。

I have the following input and I want to fire the event after pressing enter:

  <input
    matInput
    type="number"
    min="0"
    placeholder="0"
    (keyup.enter)="minValue($event)"
  />

I have also tried (keydown.enter)="minValue($event)" without success.
How can a user type a value and when pressing enter call the minValue method?

Also, when I am clicking on the input field to type a value the input box dissapears before write anything.

Thanks a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过气美图社 2025-02-16 19:18:12

尝试这样:

.html

<input
matInput
type="number"
min="0"
placeholder="0"
[(ngModel)]="myValue"
(keyup.enter)="minValue(myValue)"
/>

.ts

  minValue(evt){
    console.log(evt)
  }

demo

Try like this:

.html

<input
matInput
type="number"
min="0"
placeholder="0"
[(ngModel)]="myValue"
(keyup.enter)="minValue(myValue)"
/>

.ts

  minValue(evt){
    console.log(evt)
  }

Demo

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文