###如题,通过onChange更新自身的input不能输入中文~~
通过react的的onChange事件handler来更新自身的value,每次内容改变都会触发更新,这样就打断了中文的拼音,输入全是中文的字母,这个问题有没有谁遇到过,是怎么解决的?
求助,通过onChange更新自身的input不能输入中文
renjunqing
#1
marchen
#3
没有遇到这样的问题.中文输入的时候,并不会触发onChage事件. 我用的搜狗输入法. 不知道是否是输入法引起的?
demo如下
import React, { PropTypes, Component } from 'react'
export default class Test extends Component {
static propTypes = {
}
static defaultProps = {
}
constructor(props) {
super(props)
}
changeHandle() {
this._name.value = this._name.value
}
render() {
return (
<div>
<h1>react常见的问题</h1>
<h2>input onchange事件中文输入</h2>
{/* 重现问题 */}
name: <input type="text" defaultValue="marry" placeholder="input your name" onChange={this.changeHandle.bind(this)} ref={(node) => this._name = node}/>
</div>
)
}
}
module.exports = Test
nimojs
#4
试着对 onCompositionStart/Update/End 进行封装
或者用这个组件 react-composition https://fast-flow.github.io/react-composition/