我设法得到了价值观
Hello
和
World
在页面上呈现,但截至目前,无法修改。当我单击它时,文本光标会出现,但无法识别任何键盘输入。我该怎么做才能接收输入(如删除字符或添加字符)?
formatoc。js公司:
{...
var props = {
'name' : 'form',
'timer' : 1500,
'callback' : function(id, validity, value) {console.log(id, validity, value);},
'values': ["hello", "world"],
'node' : new FormatOC.ArrayNode({"__array__":"unique", "__type__":"string","__minimum__":1,"__maximum__":200,"__component__":"Input"})
}
React.render(React.createElement(ArrayNodeComponent, props), document.getElementById('react-component'));
...}
Array\u节点。jsx公司:
{...
childChange: function(name, valid, value) {
// update state
this.state.values[name] = value;
this.setState(this.state);
console.log(name,value);
// Call parent callback
this.props.callback(
this.props.name,
this.props.newParent.valid(this.state.values),
this.state.values
);
},
render: function() {
var that = this;
console.log("Hello World");
return (
<div id = "form">
{this.props.values.map(function(v, i) {
return (
<div>
{(that.props.node.get().constructor.name === "Parent") ?
<ParentComponent
name={that.props.name + i}
key={i}
timer={that.props.timer}
callback={that.childChange}
values={v}
newParent={that.props.node.get()}
/>
:
<NodeComponent
name={that.props.name + i}
key={i}
timer={that.props.timer}
callback={that.childChange}
value={v}
newNode={that.props.node.get()}
/>
}
</div>
)
})}
</div>
)
}
...}
节点。jsx公司:
onChange: function(event) {
that = this;
var event2 = event.target;
if (this.state.component === "Input") {
if (this.timer !== null) {
clearTimeout(this.timer);
};
this.timer = setTimeout(function(){
that.state.value = event2.value;
that.props.callback(that.props.name, that.props.newNode.valid(that.state.value), that.state.value);
}, this.props.timer);
更新:当我尝试为字段提供任何文本输入时,控制台会出现以下错误:
Uncaught TypeError: Cannot read property 'valid' of undefined
at Constructor.childChange (array_node.js:64)
at Node.js:36