代码详情如下
getChat: () => {
setTimeOut(()=>{
this.refs.chat
}, 80)
return (
<div id = 'chat' ref = 'chat'>
</div>
)
}
需求 是 调用 getchat 方法 时 生成 div 标签 并同时获取dom 元素
我的思路 是 加一段 setTimeOut
各位大神有没有其他的解决方案
代码详情如下
getChat: () => {
setTimeOut(()=>{
this.refs.chat
}, 80)
return (
<div id = 'chat' ref = 'chat'>
</div>
)
}
需求 是 调用 getchat 方法 时 生成 div 标签 并同时获取dom 元素
我的思路 是 加一段 setTimeOut
各位大神有没有其他的解决方案
function getChat(){
return document.body.appendChild( document.createElement('div') )
}