这是一个非常简单的例子。我有一个表格,我需要一个隐藏字段,所以我需要使用ref
的价值:反应参考值不显示
<form>
<input ref="num" type="hidden" name="amount" value="99"/>
</form>
var number = this.refs.num.value;
console.log(number); // nothing
console.log(this.refs.num); // shows the field
如何获得与参考价值?
'this.refs.num.value'是正确的。你能提供更多的上下文给你的代码吗?你在哪里试图抓住'this.refs'? –
@BradColthurst从一个函数。 'foo:function(){...}' – Sylar
你在哪里调用函数? –