mirror of https://github.com/ElemeFE/element
				
				
				
			TimePicker: set default value
							parent
							
								
									f600053962
								
							
						
					
					
						commit
						367018bb9e
					
				|  | @ -7,7 +7,7 @@ | |||
| </style> | ||||
| 
 | ||||
| ## Time Picker 时间选择器 | ||||
|   | ||||
| 
 | ||||
|  用于选择或输入日期 | ||||
| 
 | ||||
| ### 固定时间点 | ||||
|  | @ -91,8 +91,8 @@ | |||
|     data() { | ||||
|       return { | ||||
|         value1: '', | ||||
|         value2: '', | ||||
|         value3: '', | ||||
|         value2: new Date(2016, 9, 10, 18, 40), | ||||
|         value3: [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 9, 40)], | ||||
|         startTime: '', | ||||
|         endTime: '' | ||||
|       }; | ||||
|  |  | |||
|  | @ -72,10 +72,12 @@ | |||
|     }, | ||||
| 
 | ||||
|     data() { | ||||
|       const minTime = new Date(); | ||||
|       let defaultValue = this.$options.defaultValue; | ||||
|       defaultValue = Array.isArray(defaultValue) ? defaultValue : [defaultValue]; | ||||
|       const minTime = defaultValue[0] || new Date(); | ||||
|       const date = new Date(); | ||||
|       date.setHours(date.getHours() + 1); | ||||
|       const maxTime = date; | ||||
|       const maxTime = defaultValue[1] || date; | ||||
| 
 | ||||
|       return { | ||||
|         minTime: minTime, | ||||
|  | @ -164,7 +166,7 @@ | |||
|       } | ||||
|     }, | ||||
| 
 | ||||
|     ready() { | ||||
|     mounted() { | ||||
|       this.$nextTick(() => this.handleConfirm(true, true)); | ||||
|     } | ||||
|   }; | ||||
|  |  | |||
|  | @ -77,7 +77,7 @@ | |||
|         minutes: 0, | ||||
|         seconds: 0, | ||||
|         selectableRange: [], | ||||
|         currentDate: this.date, | ||||
|         currentDate: this.$options.defaultValue || this.date, | ||||
|         currentVisible: this.visible | ||||
|       }; | ||||
|     }, | ||||
|  |  | |||
|  | @ -399,6 +399,7 @@ export default { | |||
| 
 | ||||
|     showPicker() { | ||||
|       if (!this.picker) { | ||||
|         this.panel.defaultValue = this.value; | ||||
|         this.picker = new Vue(merge({ | ||||
|           el: document.createElement('div') | ||||
|         }, this.panel)); | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ | |||
|       } | ||||
|     }, | ||||
| 
 | ||||
|     ready() { | ||||
|     mounted() { | ||||
|       if (this.disabled) { | ||||
|         this.broadcast('option', 'disableOptions'); | ||||
|       } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 qingwei.li
						qingwei.li