以下React代码在Babel-Core CDN更改为版本5.8.24时有效,但在版本为6.1.19时未包含。我很困惑为什么这会很重要?不应该向前兼容吗?或者我只是错过了一些非常明显的东西?
提前致谢。
<html>
<head>
<script src="https://unpkg.com/react@15/dist/react.min.js">
</script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-
core/6.1.19/browser.min.js"></script>
</head>
<body>
<div id="app"></div>
<script type="text/babel">
const HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
ReactDOM.render(<HelloMessage name="John" />,
document.getElementById('app'));
</script>
</body>
</html>
答案 0 :(得分:0)
使用此脚本:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let item = indexPath.item
switch item {
case 1:
let cell = collectionView.dequeueReusableCell(forIndexPath: indexPath) as ACollectionViewCell
cell.ScoreName.text = xxx
cell.ScoreName.textColor = xxx
cell.score.text = xxx
cell.score.backgroundColor = xxx
cell.....
return cell
case 2: ...
case 3: ...
case 4: ...
case 5: ...
case 6:
let cell = collectionView.dequeueReusableCell(forIndexPath: indexPath) as BCollectionViewCell
cell.title.text = "xxx xxx"
cell.score.isHidden = true
return cell
default:
let cell = collectionView.dequeueReusableCell(forIndexPath: indexPath) as DCollectionViewCell
cell.title.text = "xxx"
cell.score.text = "xx"
cell.score.backgroundColor = .green
cell....
return cell
}
}
检查<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.24.0/babel.js"></script>
DOC。
检查工作代码:
babel-standalone