如何在React JS中显示H1中的输入值
我有一个划分2个数字并给出值的输入,因此我想在H1 Tag
<input className='input' type="number" id="" placeholder='$' onChange={(evt) => {console.log(evt.target.value / coinId.price)}}/>
coinid中显示该值。预点是todays btc Price与API的价格,但在这一点上,这不是重要的
代码,这使我获得了控制台日志的结果。有什么建议吗?谢谢。
I have one input which divides 2 number and gives value, so I want to display that value in h1 tag
<input className='input' type="number" id="" placeholder='
coinId.price is todays BTC price from API but it is not important at this point
here is code which gave me result in console log so any suggestions? Thanks.
onChange={(evt) => {console.log(evt.target.value / coinId.price)}}/>
coinId.price is todays BTC price from API but it is not important at this point
here is code which gave me result in console log so any suggestions? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您忘记了
value
属性,如果您使用React Hooks,也许您可以做这样的事情:You forgot the
value
attribute I think, and if you use React Hooks maybe you can do something like this :我能想到的一种方法之一是,通过使用Usestate,设置一个状态
You can also use useEffect, so that whenever price of bitcoin is changed, you may get updated value.
或者
For furthur reference if case,
One of the methods that I can think of is that, by using useState, set a state like
You can also use useEffect, so that whenever price of bitcoin is changed, you may get updated value.
Or
For furthur reference if case, how to make a input field value in h1?