W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
你沒辦法通過 this.props.children
取得當前組件的子元素。 因為this.props.children
返回的是組件擁有者傳遞給你的 passed onto you 子節(jié)點。
var App = React.createClass({ componentDidMount: function() { // This doesn't refer to the `span`s! It refers to the children between // last line's `<App></App>`, which are undefined. console.log(this.props.children); }, render: function() { return <div><span/><span/></div>; } }); React.render(<App></App>, mountNode);
如果想看更多地例子, 可以參考在 front page 里最后一個例子。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯系方式:
更多建議: