vue.js源代码core scedule.js学习笔记
(编辑:jimmy 日期: 2024/11/16 浏览:3 次 )
vue.js 源代码学习笔记 core scedule.js,供大家参考,具体内容如下
/* @flow */ import type Watcher from './watcher' import config from '../config' import { callHook } from '../instance/lifecycle' import { warn, nextTick, devtools } from '../util/index' const queue: Array<Watcher> = [] let has: { [key: number]: "${watcher.expression}"` : `in a component render function.` ), watcher.vm ) break } } } // reset scheduler before updated hook called const oldQueue = queue.slice() resetSchedulerState() // call updated hooks index = oldQueue.length while (index--) { watcher = oldQueue[index] vm = watcher.vm if (vm._watcher === watcher && vm._isMounted) { callHook(vm, 'updated') } } // devtool hook /* istanbul ignore if */ if (devtools && config.devtools) { devtools.emit('flush') } } /** * Push a watcher into the watcher queue. * Jobs with duplicate IDs will be skipped unless it's * pushed when the queue is being flushed. */ export function queueWatcher (watcher: Watcher) { const id = watcher.id if (has[id] == null) { has[id] = true if (!flushing) { queue.push(watcher) } else { // if already flushing, splice the watcher based on its id // if already past its id, it will be run next immediately. let i = queue.length - 1 while (i >= 0 && queue[i].id > watcher.id) { i-- } queue.splice(Math.max(i, index) + 1, 0, watcher) } // queue the flush if (!waiting) { waiting = true nextTick(flushSchedulerQueue) } } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
下一篇:lhgcalendar时间插件限制只能选择三个月的实现方法