【问题标题】:React JS How to add individual functions to the numeric input arrows?React JS 如何将单个函数添加到数字输入箭头?
【发布时间】:2021-09-21 02:31:22
【问题描述】:

据我们所知,类型号的输入集成了 2 个箭头(附加 ss)

我想知道您是否可以为每个箭头添加不同的功能。 例如,我有以下代码,但无论您按什么箭头,它都只会添加 +1:

<input onChange = {(e) => {mas(productos.descripcion, productos.cantidad,e.target.valueAsNumber)}}
 type = 'number'
 pattern = "[0-9]*"
 required
 value = {productos.cantidad}
/>

我想添加另一个函数,这样我就可以使用两个箭头,一个用于 ++1,另一个用于--1。任何提示、帮助、文档都非常感谢。

【问题讨论】:

    标签: javascript input


    【解决方案1】:

    onChange只是获取当前输入值,如果想知道是++1还是--1,可以将当前值e.target.valueAsNumber与之前的值productos.cantidad进行比较。

    【讨论】:

    • 这可以解决我的问题,但我想知道你是否可以使用箭头。
    • 不,你不能在箭头上绑定事件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-21
    • 2017-03-13
    • 1970-01-01
    • 2021-06-09
    • 2021-11-13
    • 1970-01-01
    相关资源
    最近更新 更多