如何解决如何将图标放在 React Material Ui 文本字段中?
我想将眼睛图标放在我用作密码的文本字段中,但我找不到将它放在 Material UI 中的文本字段组件中的方法。 这是代码;
<TextField
variant="outlined"
margin="dense"
required
fullWidth
placeholder={placeholder}
name={label}
type={showPassword ? "text" : type}
id={id}
inputProps={{
style: {
background: "white",BoxShadow: "rgba(0,0.24) 0px 3px 8px",height: "15px",borderRadius: "10px",width: "100%",marginRight: 0,},}}
InputProps={{
classes: { notchedOutline: classes.noBorder },endAdornment:
type === "password" ? (
<InputAdornment
position="start"
classes={{ positionStart: "0px" }}
>
<IconButton
onClick={handleClickShowPassword}
onMouseDown={handleMouseDownPassword}
>
{showPassword ? <Visibility /> : <VisibilityOff />}
</IconButton>
</InputAdornment>
) : null,}}
/>
解决方法
根据 documentation,您的装饰设置似乎基本正确。我能看到的唯一问题是您已将 InputAdornment 的位置设置为开始而不是结束。另外,您使用的 df %>%
filter(str_detect(key,'^[^+]+$')|is.na(key))
# A tibble: 4 x 2
# id key
# <dbl> <chr>
#1 2 0677219-30911
#2 3 -739812//3918
#3 5 1904-03940538
#4 6 <NA>
是错误的。我已将其包含在下面的示例中,但您可能希望将其从本节中完全删除。
试试这个:
library(tidyverse)
library(lubridate)
library(vroom)
xhamster <- vroom("xhamster.csv")
xhamster$upload_date<-as.Date(xhamster$upload_date,format="%d/%m/%Y")
xhamster$Year <- year(ymd(xhamster$upload_date))
xhamster %>%
filter(Year %in% 2007:2013) %>%
filter(grepl("Amateur",channels)) %>%
ggplot(aes(x = Year,y = ..count..)) +
geom_bar() +
scale_x_continuous(breaks = c(2007:2013),labels = c(2007:2013)) +
ylab(label = "Count") +
xlab(label = "Amateur") +
labs(title = "Usage of 'Amateur' as a tag from 2007 to 2013",caption = "Data obtained from https://sexualitics.github.io/ under a CC BY-NC-SA 3.0 license") +
theme_minimal(base_size = 14)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。