Reactjs 错误-上的未知属性“BoundryLink”<;ul>;反应分页标记中的标记
我试图在react-redux过程中应用分页,这里我面临两个问题 第一个-其给出错误-Reactjs 错误-上的未知属性“BoundryLink”<;ul>;反应分页标记中的标记,reactjs,pagination,Reactjs,Pagination,我试图在react-redux过程中应用分页,这里我面临两个问题 第一个-其给出错误-中代码行的标记上的未知属性boundryLinks 第二-在-页面:编号(state.routing.locationbeforetransforts.query.page|u no)中的MapStateTrops函数中未获取查询参数值 这是我的文件组件代码>>>> ======================== import React from 'react'; import StaticLayout
中代码行的标记上的未知属性
boundryLinks
第二-在-页面:编号(state.routing.locationbeforetransforts.query.page|u no)中的MapStateTrops
函数中未获取查询参数值
这是我的文件组件代码>>>>
========================
import React from 'react';
import StaticLayout from '../Layout/StaticLayout';
import { Link } from 'react-router-dom';
import { getBlogList } from '../actions/signupActions';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import dateFormat from 'dateformat';
import { Pagination } from 'react-bootstrap';
import { push } from 'react-router-redux';
class BlogList extends React.Component {
constructor(props){
super(props);
document.title = "Blogs";
this.changePage = this.changePage.bind(this);
}
componentDidMount() {
this.props.getBlogList();
}
//we cannot declare a string var in the Component class directly
render(){
//===pagination variable========
const per_page = 1;
let pages = 0;
if(this.props.blogListData !== undefined){
pages = Math.ceil(this.props.blogListData.count / per_page) ;
}
const current_page = this.props.page;
const start_offset = (current_page - 1) * per_page;
let start_count = 0;
//===End pagination variable========
return(
<StaticLayout>
<section id="page-title">
<div className="container clearfix">
<h1>Blog</h1>
<span>Our Latest News in Grid Layout</span>
<ol className="breadcrumb">
<li><Link to="/">Home</Link></li>
<li className="active">Blog</li>
</ol>
</div>
</section>
<section id="content">
<div className="content-wrap">
<div className="container clearfix">
<div id="posts" className="post-grid grid-container clearfix" data-layout="fitRows">
{this.props.blogListData && this.props.blogListData.blogs.map((obj, idx) => {
if(idx >= start_offset && start_count < per_page){
start_count++;
return <div className="entry clearfix" key={idx}>
<div className="entry-image">
<a href="/images/blog/full/17.jpg" data-lightbox="pic" ><img className="image_fade" src="/images/blog/grid/17.jpg" alt="Standard Post with Image" /></a>
</div>
<div className="entry-title">
<h2><a href="/">{obj.title}</a></h2>
</div>
<ul className="entry-meta clearfix">
<li><i className="icon-calendar3"></i> {dateFormat(obj.date_created, "mmm dS, yyyy")}</li>
</ul>
<div className="entry-content">
<p>{obj.content.length > 20 ? obj.content.substring(0,20)+'...' : obj.content}</p>
<a href="/"className="more-link">Read More</a>
</div>
</div>
}
}) }
<Pagination className="users-pagination pull-right" bsSize="medium" maxButtons={10} first last next prev boundryLinks items={pages} activePage={current_page} onSelect={this.changePage } />
</div>
</div>
</div>
</section>
</StaticLayout>
);
}
changePage(page){
this.props.dispatch(push('/?page_no='+page))
}
}
function mapStateToProps(state){
return {
blogListData: state.UserReducer.blogData,
page: Number(state.routing.locationBeforeTransitions.query.page_no) || 1,
}
}
function mapDispatchToProps(dispatch) {
return bindActionCreators({getBlogList: getBlogList}, dispatch)
}
export default connect(mapStateToProps, mapDispatchToProps) (BlogList);
从“React”导入React;
从“../Layout/StaticLayout”导入StaticLayout;
从'react router dom'导入{Link};
从“../actions/signupActions”导入{getBlogList};
从“redux”导入{bindActionCreators};
从'react redux'导入{connect};
从“dateFormat”导入dateFormat;
从'react bootstrap'导入{Pagination};
从“react router redux”导入{push};
类BlogList扩展了React.Component{
建造师(道具){
超级(道具);
document.title=“博客”;
this.changePage=this.changePage.bind(this);
}
componentDidMount(){
this.props.getBlogList();
}
//我们不能直接在组件类中声明字符串变量
render(){
//==分页变量========
每页常数=1;
设pages=0;
if(this.props.blogListData!==未定义){
pages=Math.ceil(this.props.blogListData.count/per_page);
}
const current_page=this.props.page;
常量开始偏移量=(当前页面-1)*每页;
让start_count=0;
//==结束分页变量========
返回(
博客
关于网格布局的最新消息
家
博客
{this.props.blogListData&&this.props.blogListData.blogs.map((obj,idx)=>{
如果(idx>=开始偏移量和开始计数<每页){
开始计数++;
返回
- {dateFormat(obj.date_created,“mmm dS,yyyy”)}
{obj.content.length>20?obj.content.substring(0,20)+'…':obj.content}
}
}) }
);
}
更改页面(第页){
此.props.dispatch(推送('/?页码='+页码))
}
}
函数MapStateTops(状态){
返回{
blogListData:state.UserReducer.blogData,
页码(state.routing.locationbeforetransforms.query.page|u no)| 1,
}
}
功能图DispatchToprops(调度){
返回bindActionCreators({getBlogList:getBlogList},dispatch)
}
导出默认连接(MapStateTrops、mapDispatchToProps)(BlogList);
请让我知道我做错了什么。boundaryLinks
是正确的道具,您的案例中有一个输入错误是的,谢谢您………第二个问题,它给出了下面的错误->>>无法读取Function.mapstateTrops[作为mapToProps]处null的属性“query”
我的Url是这样的-http://localhost:3000/blog-列表?页码=1