我已经将reactjs用于视图和引导程序进行设计。我想要每行3列,但我的设计布局看起来很乱。网格布局中断。可能是什么原因?
我的反应代码
export default class RoomList extends React.Component{
constructor(props){
super(props);
this.state = { rooms: [] }
}
componentDidMount(){
console.log('componentDidMount');
this.loadRoomFromServer();
}
loadRoomFromServer(){
$.ajax({
url:'/api/v1/rental/',
dataType:'json',
success: (data) => {
console.log('data',data);
this.setState({rooms: data.objects});
console.log('success');
},
error: (xhr, status, err) => {
console.error(url, status, err.toString());
}
});
}
render(){
let listOfRoom = this.state.rooms.map((room,id)=>{
return(
<Rooms key={id}
slug = {room.slug}
name={room.listingName}
price={room.price}
property={room.property}
gallery={room.gallery} />
);
});
console.log('listOfRoom',listOfRoom);
return(
<div className="hello">
<nav className="navbar navbar-default">
<div className="container-fluid">
<div className="navbar-header">
<button type="button" className="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span className="sr-only">Toggle navigation</span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
</button>
<a className="navbar-brand" href="#">Rental Space</a>
</div>
<div className="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul className="nav navbar-nav">
<li className="active"><a href="#">Home <span className="sr-only">(current)</span></a></li>
<li><a href="/roomlist/">Space List</a></li>
</ul>
<ul className="nav navbar-nav navbar-right">
<li><a href="#">Add Space</a></li>
</ul>
</div>
</div>
</nav>
<div className="container roomlist">
<div className="row">
{ listOfRoom }
</div>
</div>
</div>
)
}
}
class Rooms extends React.Component{
render(){
console.log('this.props.slug',this.props.slug);
let imageFile = this.props.gallery.map((image) => {
return(
<img src={image.image} className="img-fluid" width="300px" height="300px" />
);
});
return(
<div className="col-md-4">
<div className="thumbnail">
<span className = "price">{this.props.price} Rs/Month</span>
{ imageFile[0] }
</div>
<h3 className="listingName text-left">
<a href = { "/rent/" + this.props.slug }>{this.props.name}</a>
</h3>
<span className="propertySpan">
<i className = "fa fa-home"></i>
<span className="property">{this.props.property}</span>
</span>
</div>
)
}
}
我使用过bootstrap v4。我做错了什么?
页面看起来像这样 HTMLUnit
答案 0 :(得分:0)
我没有代码,我必须更多地查看它,但是我可以肯定地看到它没有产生超过第一个的行,它需要使得网格正常工作,因为我理解它。