createMarkup() { var row = this.props.row; if (row) { var html='<thead> <tr><th>名稱</th><th>值</th></tr></thead><tbody>'; for(var item in row){ html+='<tr><td>'+item+'</td><td><input type="text" id='+item+' value='+row[item]+' onchange={this.handleChange}> </td></tr>'; } html+='</tbody></Table>'; return {__html:html}; } },handleChange(e) { const value = e.target.getAttribute('id'); const object = {}; object[value] = e.target.value; this.setState(object,function () { console.log(this.state) }); },render(){<Table striped bordered condensed hover dangerouslySetInnerHTML={this.createMarkup()}/>}我想在dangerouslySetInnerHTML的字符串里面的input調(diào)用handleChange方法,該如何寫
react如何在 dangerouslySetInnerHTML里面插入方法
呼啦一陣風(fēng)
2018-09-07 10:05:47