今天使用ReactCSSTransitionGroup插件做一个简单的List列表淡入淡出动画,发现出现乱码,我确定我的编辑器使用的utf-8编码,各位大神有遇到过这样的问题吗?
League of Legends
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
var TodoList = React.createClass({
getInitialState: function() {
return {items: ['hello', 'world', 'click', 'me']};
},
handleAdd: function() {
var newItems =
this.state.items.concat([prompt('Enter some text')]);
this.setState({items: newItems});
},
handleRemove: function(i) {
var newItems = this.state.items;
newItems.splice(i, 1);
this.setState({items: newItems});
},
render: function() {
var items = this.state.items.map(function(item, i) {
return (
{item}
);
}.bind(this));
return (
{items}
);
}
});
React.render(
,
document.getElementById('app')
);

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
编辑器是
utf-8,那你确认文件编码格式是utf-8了吗?设置浏览器编码
看了一下,关键在于:
你的React代码并不是直接被浏览器使用的(React有JSX),而是要通过工具转换的,从你引用的文件来看,是这个:
具体的转换过程得自己查。或者你尝试把代码放到HTML里看看,即把上面的改成如下并放在
<body>内:。