列表反应组件的多行辅助文本

Pet*_*ack 1 reactjs material-ui

我正在尝试添加列表反应材料 ui组件的辅助文本的第二行。

我该如何修改它?在此处查看现场演示。

<ListItemText primary="Photos" secondary="first row" secondary="second row"/>
Run Code Online (Sandbox Code Playgroud)

小智 5

我编辑了(演示链接)的文件 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);
Run Code Online (Sandbox Code Playgroud)

次要道具是节点类型,您可以将道具传递为:

secondary={         
<div>
  <div>line 1</div>
  <div>line 2</div>
</div>
}
Run Code Online (Sandbox Code Playgroud)