使用来自之前项目的类似React-Route但是这个只提供了一个白色屏幕,如果我在根目录中创建一个导航链接,它会更改路径但保持白色。不知道为什么内容没有加载。还有repo上的代码:repo with code
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';
import App from './App';
import Test from './components/test';
import Home from './pages/home_page';
import './index.css';
ReactDOM.render((
<Router history={browserHistory}>
<Route path='/' component={App}>
<IndexRoute component={Home}/>
<Route path='/test' component={Test} />
</Route>
</Router>
), document.getElementById('app'))
App.js
import React, { Component } from 'react';
import './App.css';
export default class App extends Component {
render() {
return (
<div>
{this.props.childen}
</div>
);
}
}
只是添加控制台没有错误,并说它已正确编译而没有任何警告。网址确实已更改,但内容未加载到网页。
答案 0 :(得分:2)
我克隆了您的回购并发现了问题 - 这是func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return listData.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath) as! MyCollectionListViewCell
if let url = self.listData[indexPath.row]["photo"] as? String {
let urlPhoto = NSURL(string:url!)
cell.imageView.sd_setImageWithURL(urlPhoto, placeholderImage:img)
cell.imageView.contentMode = UIViewContentMode.ScaleAspectFill
cell.imageView.layer.masksToBounds = true
cell.imageView.clipsToBounds = true
}
}
App.js
- &gt; {this.props.childen}
现在有效。