Commit 1d8334dd3e9c31bf77dc00454fa948f32433f758
Committed by
GitHub
Merge pull request #1999 from SergioCrisostomo/remove-array-find
remove Array.find to make IE11 happy
Showing
1 changed file
with
4 additions
and
8 deletions
Show diff stats
src/components/date-picker/base/time-spinner.vue
... | ... | @@ -171,30 +171,26 @@ |
171 | 171 | const times = ['hours', 'minutes', 'seconds']; |
172 | 172 | this.$nextTick(() => { |
173 | 173 | times.forEach(type => { |
174 | - this.$refs[type].scrollTop = 24 * this.getItemIndex(type, this[type]); | |
174 | + this.$refs[type].scrollTop = 24 * this[`${type}List`].findIndex(obj => obj.text == this[type]); | |
175 | 175 | }); |
176 | 176 | }); |
177 | 177 | }, |
178 | 178 | formatTime (text) { |
179 | 179 | return text < 10 ? '0' + text : text; |
180 | - }, | |
181 | - getItemIndex(type, val){ | |
182 | - const item = this[`${type}List`].find(obj => obj.text == val); | |
183 | - return this[`${type}List`].indexOf(item); | |
184 | 180 | } |
185 | 181 | }, |
186 | 182 | watch: { |
187 | 183 | hours (val) { |
188 | 184 | if (!this.compiled) return; |
189 | - this.scroll('hours', this.getItemIndex('hours', val)); | |
185 | + this.scroll('hours', this.hoursList.findIndex(obj => obj.text == val)); | |
190 | 186 | }, |
191 | 187 | minutes (val) { |
192 | 188 | if (!this.compiled) return; |
193 | - this.scroll('minutes', this.getItemIndex('minutes', val)); | |
189 | + this.scroll('minutes', this.minutesList.findIndex(obj => obj.text == val)); | |
194 | 190 | }, |
195 | 191 | seconds (val) { |
196 | 192 | if (!this.compiled) return; |
197 | - this.scroll('seconds', this.getItemIndex('seconds', val)); | |
193 | + this.scroll('seconds', this.secondsList.findIndex(obj => obj.text == val)); | |
198 | 194 | } |
199 | 195 | }, |
200 | 196 | mounted () { | ... | ... |