欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue.js源代碼core scedule.js學(xué)習(xí)筆記

 更新時間:2017年07月03日 16:18:45   作者:you1you  
這篇文章主要為大家詳細介紹了vue.js源代碼core scedule.js的學(xué)習(xí)筆記,具有一定的參考價值,感興趣的小伙伴們可以參考一下

vue.js 源代碼學(xué)習(xí)筆記 core scedule.js,供大家參考,具體內(nèi)容如下

/* @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]: ?true } = {}
let circular: { [key: number]: number } = {}
let waiting = false
let flushing = false
let index = 0

/**
 * Reset the scheduler's state.
 */
function resetSchedulerState () {
 queue.length = 0
 has = {}
 if (process.env.NODE_ENV !== 'production') {
 circular = {}
 }
 waiting = flushing = false
}

/**
 * Flush both queues and run the watchers.
 */
function flushSchedulerQueue () {
 flushing = true
 let watcher, id, vm

 // Sort queue before flush.
 // This ensures that:
 // 1. Components are updated from parent to child. (because parent is always
 // created before the child)
 // 2. A component's user watchers are run before its render watcher (because
 // user watchers are created before the render watcher)
 // 3. If a component is destroyed during a parent component's watcher run,
 // its watchers can be skipped.
 queue.sort((a, b) => a.id - b.id)

 // do not cache length because more watchers might be pushed
 // as we run existing watchers
 for (index = 0; index < queue.length; index++) {
 watcher = queue[index]
 id = watcher.id
 has[id] = null
 watcher.run()
 // in dev build, check and stop circular updates.
 if (process.env.NODE_ENV !== 'production' && has[id] != null) {
  circular[id] = (circular[id] || 0) + 1
  if (circular[id] > config._maxUpdateCount) {
  warn(
   'You may have an infinite update loop ' + (
   watcher.user
    ? `in watcher with expression "${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)
 }
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue devserver及其配置方法

    vue devserver及其配置方法

    這篇文章主要介紹了vue devserver及其配置方法,本文結(jié)合示例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-12-12
  • vue3自定義hooks/可組合函數(shù)方式

    vue3自定義hooks/可組合函數(shù)方式

    這篇文章主要介紹了vue3自定義hooks/可組合函數(shù)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • Vue使用高德地圖搭建實時公交應(yīng)用功能(地圖 + 附近站點+線路詳情 + 輸入提示+換乘詳情)

    Vue使用高德地圖搭建實時公交應(yīng)用功能(地圖 + 附近站點+線路詳情 + 輸入提示+換乘詳情)

    這篇文章主要介紹了vue中使用高德地圖搭建實時公交應(yīng)用(地圖 + 附近站點+線路詳情 + 輸入提示+換乘詳情),主要是讓大家熟悉下高德地圖在vue中的使用及vue的常用指令,需要的朋友可以參考下
    2018-05-05
  • 深入探究Vue中探究組合式API的奧秘

    深入探究Vue中探究組合式API的奧秘

    Vue?3中引入了組合式API,它是一種新的代碼組織方式,旨在讓開發(fā)者更靈活地組織和重用Vue組件的邏輯,下面我們就來學(xué)習(xí)一下Vue中常見組合式API的使用吧
    2023-11-11
  • Vue使用openlayers加載天地圖

    Vue使用openlayers加載天地圖

    這篇文章主要為大家詳細介紹了Vue如何使用openlayers加載天地圖,文中的示例代碼講解詳細,具有一定的借鑒價值,感興趣的小伙伴可以了解下
    2024-02-02
  • vue3中unplugin-auto-import自動引入示例代碼

    vue3中unplugin-auto-import自動引入示例代碼

    unplugin-auto-import 這個插件是為了解決在開發(fā)中的導(dǎo)入問題,下面這篇文章主要給大家介紹了關(guān)于vue3中unplugin-auto-import自動引入的相關(guān)資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-02-02
  • ElementUI表單驗證validate和validateField的使用及區(qū)別

    ElementUI表單驗證validate和validateField的使用及區(qū)別

    Element-UI作為前端框架,最常使用到的就是表單驗證,下面這篇文章主要給大家介紹了關(guān)于ElementUI表單驗證validate和validateField的使用及區(qū)別,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-02-02
  • vue-cli 3.0 自定義vue.config.js文件,多頁構(gòu)建的方法

    vue-cli 3.0 自定義vue.config.js文件,多頁構(gòu)建的方法

    今天小編就為大家分享一篇vue-cli 3.0 自定義vue.config.js文件,多頁構(gòu)建的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09
  • 深入探究Vue中$nextTick的實現(xiàn)原理

    深入探究Vue中$nextTick的實現(xiàn)原理

    這篇文章主要為大家詳細介紹Vue中$nextTick的實現(xiàn)原理,文中的示例代碼講解詳細,對我們深入了解Vue有一定的幫助,需要的小伙伴可以參考一下
    2023-06-06
  • Ant Design Upload 文件上傳功能的實現(xiàn)

    Ant Design Upload 文件上傳功能的實現(xiàn)

    這篇文章主要介紹了Ant Design Upload 文件上傳功能的實現(xiàn)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-04-04

最新評論