How to provide Picker a default “Please select…” option?

前端 未结 3 709
刺人心
刺人心 2021-02-07 14:49

I\'d like to make my Picker to show a \"default option\" on startup. That means: something like \"Please select an option\".

I\'ve tried to add a option manually with th

3条回答
  •  孤街浪徒
    2021-02-07 15:37

    You can add a conditional to your handleChangeOption so that it would only set state when the value is not 0 (the Please select an option... Picker). Something like:

    handleChangeOption(val) {
      if (val !== 0) {
        this.setState({selectedValue: val});
      }
    }
    
    ...
      
     
        
           
           
           
        
    
    

提交回复
热议问题