javascript - 排版文本没有换行
问题描述
这是我的聊天框组件,我将聊天映射到弹性框,但排版元素没有用多行消息打破界限
import React from "react";
import Chip from "@material-ui/core/Chip";
import Typography from "@material-ui/core/Typography";
import { useStyles } from "./dashboad";
import { GlobalContext } from "../context";
import Box from "@material-ui/core/Box";
const Chat = () => {
const classes = useStyles();
const { chats, activeTopic } = GlobalContext();
if (activeTopic) {
return (
<div className={classes.chat}>
<div
style={{
height: "100%",
overflowY: "scroll",
overflowX: "hidden",
width: "100%",
}}
>
{chats[activeTopic].map((chat, i) => (
<div className={classes.flex2} key={i}>
<Chip label={chat.from} className={classes.chip} />
<Typography component="p">{chat.msg}</Typography>
</div>
))}
</div>
</div>
);
}
return <div>Loading</div>;
};
export default Chat;
这是我对 flex2 类的样式
flex2: {
display: "flex",
alignItems: "center",
justifyContent: "flex-start",
width: "80%",
height: "auto",
"& > *": { marginRight: "5px" },
},
解决方案
推荐阅读
- java - 从 JComboBox 中选择 JTree 节点,反之亦然
- wordpress - WooCommerce 类别小部件中的锚链接
- mysql - MYSQL求和基于左连接中其他表的if条件
- r - 在设定的端点之间对时间序列的一部分求和
- python-3.x - Mac OS版本10.14.15黑寡妇背景下py2app的问题
- c# - 无法使用 iTextSharp 读取带有 Times new roman 字体的文本
- drupal - Drupal 7 视图过滤器 - 将 URL 获取参数“Items_Per_Page”更改为“Items”
- c# - 我想从我的列表中更改每一行的背景颜色并用 Xaml 显示它
- python - 使用python,通过从列表中提取键:值来创建字典
- java - XML 路由中的 Apache Camel 简单谓词不起作用 - 需要将标头转换为字符串?