1 回答
TA贡献1880条经验 获得超4个赞
方法
直接传递<Icon />
给相关的道具就可以了。
<ShowMoreText more={<ExpandMore />} less={<ExpandLess />} ... />
来源
import React, { useState } from "react";
import "./styles.css";
import ShowMoreText from "react-show-more-text";
import ExpandLess from "@material-ui/icons/ExpandLess";
import ExpandMore from "@material-ui/icons/ExpandMore";
export default function App() {
const [expand, setExpand] = useState(false);
const onClick = () => {
setExpand(!expand);
};
const text = "12313131313131311";
return (
<div className="App">
<ShowMoreText
lines={2}
more={<ExpandMore />}
less={<ExpandLess />}
onClick={onClick}
expanded={expand}
width={30}
>
{text}
</ShowMoreText>
</div>
);
}
- 1 回答
- 0 关注
- 86 浏览
添加回答
举报