gpt4 book ai didi

reactjs - 列表 react 组件的多行辅助文本

转载 作者:行者123 更新时间:2023-12-02 00:29:37 24 4
gpt4 key购买 nike

我正在尝试添加列表的辅助文本的第二行 react material ui组件。

如何修改?查看现场演示 here .

<ListItemText primary="Photos" secondary="first row" secondary="second row"/>

最佳答案

我编辑了(演示链接)的文件 demo.js

import React from "react";
import PropTypes from "prop-types";
import { withStyles } from "@material-ui/core/styles";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText";
import Avatar from "@material-ui/core/Avatar";
import ImageIcon from "@material-ui/icons/Image";
import WorkIcon from "@material-ui/icons/Work";
import BeachAccessIcon from "@material-ui/icons/BeachAccess";

const styles = theme => ({
root: {
width: "100%",
maxWidth: 360,
backgroundColor: theme.palette.background.paper
}
});

function FolderList(props) {
const { classes } = props;
return (
<div className={classes.root}>
<List>
<ListItem>
<Avatar>
<ImageIcon />
</Avatar>
<ListItemText
primary="Photos"
secondary={
<div>
<div>line 1</div>
<div>line 2</div>
</div>
}
/>
</ListItem>
<ListItem>
<Avatar>
<WorkIcon />
</Avatar>
<ListItemText primary="Work" secondary="Jan 7, 2014" />
</ListItem>
<ListItem>
<Avatar>
<BeachAccessIcon />
</Avatar>
<ListItemText primary="Vacation" secondary="July 20, 2014" />
</ListItem>
</List>
</div>
);
}

FolderList.propTypes = {
classes: PropTypes.object.isRequired
};

export default withStyles(styles)(FolderList);

辅助 Prop 是节点类型,您可以将 Prop 传递为:

secondary={         
<div>
<div>line 1</div>
<div>line 2</div>
</div>
}

关于reactjs - 列表 react 组件的多行辅助文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52401960/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com