如何设置Picker React native的Selected项值

时间:2017-12-27 18:48:44

标签: react-native

**这里是代码首先动态推送选择器上的值*****

const refItem = [];
for (var i = 0; i < this.state.ref_val1.length, i < this.state.ref_val2.length; i++) {

  s = this.state.ref_val1[i];
  val = this.state.ref_val2[i];
  refItem.push(<Picker.Item key={i} value={val} label={s} />);
}

****然后将其设置为州......但它不起作用****

<Picker
      selectedValue={this.state.selectedVar}
      onValueChange={(itemValue) => (this.setState({ selectedVar: itemValue }))} >

      {refItem}

    </Picker>

0 个答案:

没有答案