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

前端 未结 3 1887
盖世英雄少女心
盖世英雄少女心 2021-02-07 15:00

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:28

    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});
      }
    }
    
    ...
      
     
        
           
           
           
        
    
    

提交回复
热议问题