类型错误:无法在 react-native 中设置未定义的属性“0”

时间:2021-07-26 06:26:53

标签: ref

我是初学者,尝试使用 react-native 制作应用程序。 我尝试使用 'ref' 来关注一些文本输入。还有 3~4 个文本输入。 我给他们“参考编号”,如下所示

const barcode = [];


<input ref={c => {this.barcode[0]=c}}/>
<input ref={c => {this.barcode[1]=c}}/>
<input ref={c => {this.barcode[2]=c}}/>

导致如下错误

TypeError: 无法在 react-native 中设置 undefined 的属性“0”

0 个答案:

没有答案
相关问题