引用两个cdn文件,没用
引用没有用咋办???
引用没有用咋办???
2016-10-09
react版本会一直变化 试试下面的
<script type="text/javascript" src="https://npmcdn.com/react@latest/dist/react-with-addons.js"></script>
<script type="text/javascript" src="https://npmcdn.com/react-dom@latest/dist/react-dom.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
而且 0.14版本后要把react.func改为reactDOM.func呦~func指各种函数~
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Document</title>
<script type="text/javascript" src="https://npmcdn.com/react@latest/dist/react-with-addons.js"></script>
<script type="text/javascript" src="https://npmcdn.com/react-dom@latest/dist/react-dom.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
</head>
<body>
<div id="container"></div>
<script type="text/babel">
var TestClickComponent=React.createClass({
handleClick:function(event){
var tipE=ReactDOM.findDOMNode(this.refs.tip);
if(tipE.style.display==='none'){
tipE.style.display='inline';
}else{
tipE.style.display='none';
}
event.stopPropagationgation();
event.preventDefault();
},
render:function(){
return(
<div>
<button onClick={this.handleClick}>显示|隐藏</button><span ref="tip">测试点击</span>
</div>
);
}
});
var TestInputComponent=React.createClass({
getInitialState:function(){
return{
inputContent:''
}
},
changeHandler:function(event){
this.setState({
inputContent:event.target.value
});
event.preventDefault();
event.stopPropagationgation();
},
render:function(){
return(
<div>
<input type="text" onChange={this.changeHandler}/><span>{this.state.inputContent}</span>
</div>
);
}
});
ReactDOM.render(
<div>
<TestClickComponent/>
<br/><br/><br/>
<TestInputComponent/>
</div>
,document.getElementById('container'));
</script>
</body>
</html>
试试我写的 我自己没问题~
大神我用了还是运行不了,求赐教:
控制台显示:Download the React DevTools for a better development experience: https://fb.me/react-devtools
代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="https://npmcdn.com/react@latest/dist/react-with-addons.js"></script>
<script type="text/javascript" src="https://npmcdn.com/react-dom@latest/dist/react-dom.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
</head>
<body>
<div id="container">
</div>
</body>
<script type="text/babel">
var testClick = React.createClass({
render:function(){
return (
<div>
<button>显示|影藏</button><span>点击测试</span>
</div>
);
}
});
var testInput = React.createClass({
getInitialState:function(){
return {
inputContent:''
}
},
render:function(){
return (
<div>
<input type="text" /><span>{this.state.inputContent}</span>
</div>
);
}
});
ReactDOM.render(
<div>
<testClick/>
<br/><br/><br/>
<testInput/>
</div>,
document.getElementById("container"));
</script>
</html>
举报