[英]MUI How to add text with textfield input props?
Hello I have a text field with InputProps which is a icon that triggers an onClick您好,我有一个带有 InputProps 的文本字段,这是一个触发 onClick 的图标
<TextField
id="outlined-basic"
label="Type Tag Name"
variant="outlined"
fullWidth
InputProps={{
endAdornment: <AddIcon sx={{ cursor: "pointer" }} onClick={(e) => handleTagAdd(e)} />,
}}
/>
the handleTagAdd function will add e.target.value to some state, however I am getting undefined values when I console.log e.target.value handleTagAdd 函数会将 e.target.value 添加到某个状态,但是当我 console.log e.target.value 时我得到未定义的值
Is it not the event from the textfield?这不是来自文本字段的事件吗?
endAdornment
is a div that contains a button. endAdornment
是一个包含按钮的 div。 Therefore this HTML element doesn't have a value property and e.target.value
returns undefined
.因此这个 HTML 元素没有 value 属性并且
e.target.value
返回undefined
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.