為啥我上來就報React.createClass is not a function啊
Uncaught TypeError: React.creatClass is not a function
源碼如下:
<!DOCTYPE html> ? ?
<html lang="en"> ? ?
<head> ? ?
<meta charset="UTF-8"> ? ?
<script src="http://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script> ? ?
<script src="http://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script> ? ?
<title>Document</title> ? ?
</head> ? ?
<body> ? ?
? ?
<div id="container"></div> ? ?
<script type="text/jsx"> ? ?
console.log(React) ? ?
var TestClickComponent = React.creatClass({ ? ?
render:function(){ ? ?
? return ( ? ?
? ? <div> ? ?
? ? ? <button>顯示|隱藏</button><span>點擊測試</span> ? ?
</div> ? ?
); ? ?
? } ? ?
}); ? ?
var TestInputComponent = React.creatClass({ ? ?
getInitialState:function(){ ? ?
? return{ ? ?
? ? inputContent:"" ? ?
} ? ?
}, ? ?
render:function(){ ? ?
? return ( ? ?
? ? <div> ? ?
? ? ? <input type="text"/><span>{this.state.inputContent}</span> ? ?
? ? ? </div> ? ?
); ? ?
} ? ?
}); ? ?
React.render( ? ?
<div> ? ?
<TestClickComponent/> ? ?
<TestInputComponent/> ? ?
</div>, ? ?
document.getElementById('container')); ? ?
</script> ? ?
</body> ? ?
</html> ? ?
2020-08-05
我也遇到相同的問題,應(yīng)該是版本不對吧。
2019-07-13
使用es6語法
2017-05-10
應(yīng)該是 React.createClass,你少些了一個creat(e)