简体   繁体   English

如何在 ReactJS 中获取用户输入时显示具有 3 个属性的只读字段?

[英]How to display readonly field with 3 attributes while taking user input in ReactJS?

The user will select currency,write amount, and select time(hour,day,month,year).用户将 select 币种,写入金额,select 时间(时、日、月、年)。 I need to make a functional component which takes all these values provided by user and displays a read-only value in 1 box (as show).我需要制作一个功能组件,它采用用户提供的所有这些值并在 1 个框中显示一个只读值(如图所示)。 在此处输入图像描述

The user input box is supposed to look like this用户输入框应该是这样的在此处输入图像描述

Also, It would be very helpful if anybody can style it similarly or atleast tell how can I. (using CSS, scss, antD, tailwind anything).此外,如果有人可以类似地设计它或至少告诉我如何设计,那将非常有帮助。(使用 CSS、scss、antD、tailwind 任何东西)。

PS: Don't avoid mentioning the placeholder. PS:不要避免提及占位符。

Try to do it step by step.尝试一步一步地去做。 Create what you want in the simplest/ugliest way possible.以最简单/最丑陋的方式创造你想要的东西。 It doesn't matter how it looks, if it works it is enough.不管它看起来如何,只要它有效就足够了。

  1. You need to create a component which renders a select for currency, select for time, an input for value and a div to display the currency symbol.您需要创建一个组件,该组件呈现货币的 select、时间的 select、价值的输入和显示货币符号的div
  2. Use javascript to change the currency symbol when user selects a currency using the select.当用户使用 select 选择货币时,使用 javascript 更改货币符号。 Your component should be able to handle value and onChange that receives from the parent component.您的组件应该能够处理从父组件接收的valueonChange
  3. All you have to do is to use CSS.您所要做的就是使用 CSS。 Read mui documentation for components and inspect elements to see how you should change styles.阅读组件的 mui 文档并检查元素以了解应如何更改 styles。 You can also take a look at mui github code.你也可以看看 mui github 代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM