如何动态创建 refs 反应原生视频
How to dynamically create refs react native video
既然不能只使用字符串,我该如何为视频列表创建动态引用?
例如如何将其变成动态的东西
ref={(ref) => { this.player = ref }}
以前什么时候可以做到这一点
x = ['ref1', 'ref2']
ref={x[index]}
你可以这样试试:-
constructor(props) {
super(props)
....
this.myInput = [];
}
...
render() { // or return depending on your code
for (i=0;i<=n;i++) {
... your code... // i will go with TextInput for now
<TextInput
ref={(input) => {this.myInput[i]=input}}
multiline={true}
style={{ padding: 10, fontSize: 15 * myr, alignSelf: 'center', backgroundColor: 'red' }}
onChangeText={(text) => Email = text}
placeholder="Email*"
/>
}
}
既然不能只使用字符串,我该如何为视频列表创建动态引用?
例如如何将其变成动态的东西
ref={(ref) => { this.player = ref }}
以前什么时候可以做到这一点
x = ['ref1', 'ref2']
ref={x[index]}
你可以这样试试:-
constructor(props) {
super(props)
....
this.myInput = [];
}
...
render() { // or return depending on your code
for (i=0;i<=n;i++) {
... your code... // i will go with TextInput for now
<TextInput
ref={(input) => {this.myInput[i]=input}}
multiline={true}
style={{ padding: 10, fontSize: 15 * myr, alignSelf: 'center', backgroundColor: 'red' }}
onChangeText={(text) => Email = text}
placeholder="Email*"
/>
}
}