Pārlūkot izejas kodu

解决查体数字输入后删除placeholder没有渲染问题

luolei 5 gadi atpakaļ
vecāks
revīzija
9be53f0718
1 mainītis faili ar 8 papildinājumiem un 0 dzēšanām
  1. 8 0
      src/components/NumberDrop/index.jsx

+ 8 - 0
src/components/NumberDrop/index.jsx

@@ -195,6 +195,14 @@ class NumberDrop extends Component{
       saveDoms&&saveDoms(that.$span);
     })
   }
+  componentWillReceiveProps(nextProps){
+    if((nextProps.placeholder == this.props.placeholder)&&(nextProps.value == this.props.value)){
+      return
+    }
+    this.setState({
+      placeholder:nextProps.value||nextProps.placeholder
+    })
+  }
   render(){
     const {prefix,suffix,show,value,handleHide,allClick} = this.props;
     const {placeholder,hasSelect} = this.state;