我試圖在Android瀏覽器中運行http://facebook.github.io/react/docs的一些示例,它們不起作用 - 有空頁面。所有頁面都是從本地運行的django dev web服務器提供的,並且除了那些使用React的工作正常以外。完全相同的鏈接在筆記本電腦上正常工作。從他們的文檔「如果您想在觸摸設備(即手機或平板電腦)上使用React,只需調用React.initializeTouchEvents(true);將其打開。」我認爲在移動設備上運行應該沒有問題。我在這裏錯過了一些陷阱嗎? 來源是:Android的Facebook上的反應
<!DOCTYPE html>
<html>
<head>
<title>Hello React</title>
<script src="/static/phs/js/react.js"></script>
<script src="/static/phs/js/JSXTransformer.js"></script>
</head>
<body>
<div id="example"></div>
<div id="example1"></div>
<script type="text/jsx">
/** @jsx React.DOM */
React.initializeTouchEvents(true);
var HelloWorld = React.createClass({
render: function() {
return (
<p>
Hello, <input type="text" placeholder="Your name here" />!
It is {this.props.date.toTimeString()}
</p>
);
}
});
setInterval(function() {
React.renderComponent(
<HelloWorld date={new Date()} />,
document.getElementById('example')
);
}, 1000);
var LikeButton = React.createClass({
getInitialState: function() {
return {liked: false};
},
handleClick: function(event) {
this.setState({liked: !this.state.liked});
},
render: function() {
var text = this.state.liked ? 'like' : 'unlike';
return (
<p onClick={this.handleClick}>
You {text} this. Click to toggle.
</p>
);
}
});
React.renderComponent(
<LikeButton />,
document.getElementById('example1')
);
</script>
</body>
</html>
根據要求包含有效代碼。 –
答案結果很簡單 - Dolphin和Android(2.3.5)瀏覽器都不支持這種新技術。通過安裝最新的Firefox for Android進行修復。 –