close

答:

另寫一個function出來接收多個參數

onChangeText去呼叫這個參數,並且帶入自訂參數即可

ex: 

onChangeText={(text) => this.handleChange(text, p)}

--

What is name supposed to be? All you're doing is setting name to an integer, but here's a way to make it work:

handleChange(text, name) {
  console.log("test: "text+" "+name);
}

//http://facebook.github.io/react-native/releases/0.23/docs/textinput.html
for (let p = 0; p < 20; p++){
  products.push (<TextInput onChangeText={(text) => this.handleChange(text, p)}></TextInput> );
}

--

轉自 https://stackoverflow.com/questions/41467700/pass-multiple-params-onchangetext-input-element-function-react-native

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dizzy03 的頭像
    dizzy03

    碎碎念

    dizzy03 發表在 痞客邦 留言(0) 人氣()