findDOMNode提示not function
<!DOCTYPE?html> <html> ????<head> ????????<meta?charset="utf-8"> ????</head> ????<body> ????<div?id="example"></div> ????<script?src="js/react.js"></script> ????<script?src="js/react-dom.js"></script> ????<script?src="js/browser.min.js"></script> ????<script?type="text/babel"> ????????var?TestClickComponent?=?React.createClass({ ????????????handleClick:?function(event){ ????????????????var?tipE?=?React.getDOMNode(this.refs.tip); ????????????????if(tipE.style.display?===?'none'){ ????????????????????tipE.style.display?=?'inline'; ????????????????} ????????????????else{ ????????????????????tipE.style.display?=?'none'; ????????????????} ????????????}, ????????????render:?function(){ ????????????????return?( ????????????????????<div> ????????????????????????<button?onClick={this.handleClick}>顯示|隱藏</button> ????????????????????????<span?ref="tip">測(cè)試點(diǎn)擊</span> ????????????????????</div> ????????????????????) ????????????} ????????}); ????????var?TestInputComponent?=?React.createClass({ ????????????getInitialState:?function(){ ????????????????return?{ ????????????????????inputContent:?'' ????????????????} ????????????}, ????????????changeHandler:?function(event){ ????????????????this.setState({ ????????????????????inputContent:?event.target.value ????????????????}) ????????????????event.stopPropagation(); ????????????????event.preventDefault(); ????????????} ????????????, ????????????render:?function(){ ????????????????return?( ????????????????????<div> ????????????????????????<input?type="text"?onChange={this.changeHandler}/> ????????????????????????<span>{this.state.inputContent}</span> ????????????????????</div> ????????????????????) ????????????} ????????}); ????????ReactDOM.render( ????????????<div> ????????????????<TestClickComponent></TestClickComponent> ????????????????<br?/> ????????????????<TestInputComponent></TestInputComponent> ????????????</div> ????????????, ????????????document.getElementById('example') ????????????) ????</script> ????</body> </html>
問(wèn)題如標(biāo)題啊
2018-03-11
return (
<div>
<button onClick={this.handleClick}>顯示|隱藏</button><span style={{display:'none'}} ref="tip">測(cè)試點(diǎn)擊</span>
</div>
);
在span標(biāo)簽給定style就不會(huì)了
2017-11-13
有沒(méi)有在獲取tipE.style.display的時(shí)候,display是undefined的情況?。?!
2017-07-23
15版本以后,
先 import ReactDOM from 'react-dom';
然后 ReactDOM.findDOMNode(this.refs.tip);
2017-05-19
你先看看你Reac.min.js是什么版本的,15版本以后用ReactDOM.findDOMNode(this.refs.xx)
2016-11-20
0.14.8版本及以前用 this.getDOMNode() 或者 this.findDOMNode(this.refs.tip)
15.0版本后用?ReactDOM.findDOMNode(this.refs.tip);
2016-07-28
版本問(wèn)題,0.14以后已經(jīng)將React拆分了兩個(gè)庫(kù) react 和 react-dom 而getDOMNode改為react-dom中的findDOMNode,所以如果你上面的代碼是引用了最新版本的這兩個(gè)庫(kù),那么想使用find...的話需要ReactDOM.findDOMNode()
2016-07-05
1.引用老師的庫(kù)試試
? ? <script src="http://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
? ? <script src="
2.將ReactDOM換成React。
是版本兼容問(wèn)題,望采納!
2016-06-29
var?tipE?=?React.findDOMNode(this.refs.tip);
改成這樣,get是獲取,find是查找
2016-06-29
var?tipE?=?React.getDOMNodes(this.refs.tip);
在Node后面加個(gè)s試試