Here是完整的项目,我创建了一个使用最少CSS且没有我创建CSS的新项目。结果是一样的。
这是我的Home
类的代码:
class Home extends React.Component{
state={};
render() {
return (
<div>
<div className="container">
<h1>Assignment Submission System</h1>
<p className="lead">To get latest notification, click
<tab>
<Link to={"/notifications"}>
here
</Link>
</tab>
.
</p>
<p>All enrolled class-rooms, assignment to-do list are shown.</p>
<h2 className="mt-4">Class-rooms:</h2>
<ClassRoomUnit displayName={"class 1"} classID={"4324ax"} hLink={"/class/asd"}/>
<ClassRoomUnit displayName={"class 2"} classID={"4324ax"} hLink={"/class/xzx"}/>
<ClassRoomUnit displayName={"class 3"} classID={"4324ax"} hLink={"/class/asd"}/>
<ClassRoomUnit displayName={"class 4"} classID={"4324ax"} hLink={"/class/asd"}/>
</div>
</div>
);
}
}
export default Home;
但是问题是,当只有很少的ClassRoomUnit
项目时,它可以正确呈现:
但是当我添加更多ClassRoomUnit
时,尽管滚动条仍然存在,但第一部分和许多项目消失了:
答案 0 :(得分:1)
必须有一些CSS,某些类会导致这种情况。您能分叉我的示例stackblitz,对代码进行更改以查看我们是否可以在此处复制大小写吗?如果我们都能看到效果,则帮助起来会容易得多。
我的 index.js 代码:
import React, { Component } from 'react';
import { render } from 'react-dom';
import Hello from './Hello';
import './style.css';
class ClassRoomUnit extends React.Component {
constructor(props) {
super(props);
this.state = { displayName: this.props.displayName, classID: this.props.classID, hLink: this.props.hLink }
}
render() {
return (<div class='row'>
<div class='col-4 themed-grid-col'> {this.state.displayName} </div>
<div class='col-4 themed-grid-col'> {this.state.classID} </div>
<div class='col-4 themed-grid-col'> <a href={this.state.hLink}>Go to class room</a> </div>
</div>)
}
}
class App extends Component {
constructor() {
super();
this.state = {
name: 'React'
};
}
render() {
return (
<div>
<div className="container">
<h1>Assignment Submission System</h1>
<p className="lead">To get latest notification, click here
.
</p>
<p>All enrolled class-rooms, assignment to-do list are shown.</p>
<h2 className="mt-4">Class-rooms:</h2>
<ClassRoomUnit displayName={"class 1"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 2"} classID={"4324ax"} hLink={"/class/xzx"} />
<ClassRoomUnit displayName={"class 3"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 4"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 5"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 6"} classID={"4324ax"} hLink={"/class/xzx"} />
<ClassRoomUnit displayName={"class 7"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 8"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 9"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 10"} classID={"4324ax"} hLink={"/class/xzx"} />
<ClassRoomUnit displayName={"class 11"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 12"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 13"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 14"} classID={"4324ax"} hLink={"/class/xzx"} />
<ClassRoomUnit displayName={"class 15"} classID={"4324ax"} hLink={"/class/asd"} />
<ClassRoomUnit displayName={"class 16"} classID={"4324ax"} hLink={"/class/asd"} />
</div>
</div>
);
}
}
render(<App />, document.getElementById('root'));
答案 1 :(得分:0)