Fer*_*uza 2 reactjs react-router
我有问题,我正在使用 react-router 通过单击链接“更多”来访问完整的信息新闻页面,在我更改这两个页面中的某些内容之前,所有内容都可以正常显示和呈现。
FullInfoNews.js
export class FullInfoNews extends React.Component {
render (){
return (
<div>
<div className="row">
<div className="about-title">
<div className="container">
<h2>{this.props.news.body}</h2>
<p>{this.props.news.title} </p>
<img className="center-block" src={this.props.news.image} />
</div>
</div>
</div>
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
FullInfoNewsContainer.js
export default class FullInfoMediaContainer extends React.Component{
constructor(){
super();
this.state={
news:[]
}
}
componentDidMount(){
console.log('componentDidMount777');
const url='http://new-sciencepark.1gb.ru/api/getNewsById/'+this.props.params.id+'?lang=Ru' ;
superagent
.get(url)
.query(null)
.set('Accept', 'application/json')
.end ((error, response)=>{
const news=response.body.data.news
console.log(JSON.stringify(news));
this.setState({
news: news
})
})
}
render(){
console.log(this.props)
const {params}=this.props;
return(
<div>
{params.id}
<FullInfoNews news={this.state.news} />
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
}
问题是所有文件都没有加载并显示 404(未找到)错误。为什么我不明白?也许是 DOM 的问题?
索引.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Technopark site</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css" />
<link rel="stylesheet" href="app/style.css">
<script src="https://maps.googleapis.com/maps/api/js?libraries=visualization&key=AIzaSyD1USlQFgU5SK9iHulGnQwUEP7sB-d4Cew"></script>
<script src="app/js/jquery-2.1.3.min.js"></script>
</head>
<body>
<div id="app"></div>
<script src="/app/bundle.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
导航到通过阵营路由器组件的URL是不一样的进入他们的网址直接进入浏览器(基本上,当你刷新页面会发生什么)。
也就是说,如果您启动在端口5000的应用程序,打开浏览器,进入localhost:5000,然后点击一个按钮,推“/第1页”到浏览器历史记录,以便你在结束了localhost:5000/page1,那是不是就像打开你的浏览器一样,localhost:5000/page1在 URL 栏中键入并按 Enter。这是客户端与服务器端路由。
你能告诉我们你的 index.html 吗?
| 归档时间: |
|
| 查看次数: |
2802 次 |
| 最近记录: |