for(var index in preguntas.questions) {
var attr1 = preguntas.questions[index]
console.log(sum + " ***********************************************pregunta" + attr1.text )
for(var index2 in attr1.answers) {
var attr4 = attr1.answers[index2];
respuesta.push(
<View key = {index2} >
<RadioButton onPress={() => this.onSubmitPressed(index2)} >
<Text>{attr4}</Text>
</RadioButton>
</View >
)
}
questions.push(
<View key = {index}>
<View>
<Text >{attr1.text}</Text>
{respuesta}
</View>
</View>
)
var respuesta = [];
/*for(var index55 in attr2.answers) {
var attr4 = attr2.answers[index2];
console.log(sum + " ***********************************************" + attr4 )
respuesta.push(`enter code here`
<View key = {index55}>
<View>
<Text >{attr4}</Text>
</View>
</View>
)
}*/
}
早上好,我正在尝试运行onPubmitPressed上的onpres函数,但它不会让我和我得到以下错误 ReactNativeJS:NETWORK错误:TypeError:undefined不是函数(评估'this.onSubmitPressed(index2)')
代码在renderMovie函数中 如果我可以帮助那些问候
答案 0 :(得分:1)
所以看起来onSubmitPressed没有定义,你需要做的是在你的组件中声明该函数,然后如果你想使用状态和你内部的任何其他值,还要绑定(this)。 p>
onSubmitPressed(index2) {
//Do whatever you would like on your submit
}
constructor(props) {
super(props)
this.state = {};
this.onSubmitPressed = this.onSubmitPressed.bind(this);
}