我是 React 的新手,我正在尝试输出一个包含用户信息的表。但是 Eslint 一直给我以下错误:
[eslint] Missing "key" prop for element in iterator [react/jsx-key]
我不确定我这样做是否正确,但我为用户列表中的每个人分配了一个唯一的 ID 号,但不确定为什么错误持续存在。
所以在我的 PeopleCard.js 中,我有以下内容:
import React from "react";
import {
Card,
CardImg,
CardText,
CardBody,
CardTitle,
CardSubtitle,
Button
} from "reactstrap";
import PropTypes from "prop-types";
class PeopleCard extends React.Component {
static propTypes = {
person: PropTypes.object,
id: PropTypes.number,
name: PropTypes.string,
company: PropTypes.string,
description: PropTypes.string
};
render() {
return (
<div>
<Card>
<CardImg
top
width="100%"
src="https://via.placeholder.com/318x180.png"
alt="Card image cap"
/>
<CardBody>
<CardTitle>{this.props.person.name}</CardTitle>
<CardSubtitle>{this.props.person.company}</CardSubtitle>
<CardText>{this.props.person.description}</CardText>
<Button>Button</Button>
</CardBody> …Run Code Online (Sandbox Code Playgroud) 在Javascript程序中(不允许CSS,所有样式都在Javascript中完成).
我编写了一个程序,当单击(选中)时,该程序会增加表格中单元格的边框粗细.我通过将原始边框厚度设置为"薄"然后单击时将边框粗细更改为"粗"来完成此操作.
但是当单元格被"选中"时,单元格的宽度和高度会扩大,这使得每次进行单元格选择时表格都会移动.
有办法防止这种情况吗?