最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue2源碼解析之自定義指令

 更新時(shí)間:2023年05月25日 16:51:58   作者:1undefined2  
自定義指令,其實(shí)就是在vue提供的鉤子中寫代碼,這篇文章將從源碼的角度,帶大家深入了解一下Vue2種自定義指令的實(shí)現(xiàn)與使用,需要的可以參考一下

基本使用

自定義指令,其實(shí)就是在vue提供的鉤子中寫代碼,而這個(gè)鉤子的執(zhí)行是在dom渲染的不同階段執(zhí)行不同的鉤子;

自定義指令的兩種方式

// 全局
// 注冊(cè)一個(gè)全局自定義指令 `v-focus`  
Vue.directive('focus', {  
    // 當(dāng)被綁定的元素插入到 DOM 中時(shí)……  
    inserted: function (el) {  
        // 聚焦元素  
        el.focus()  
    }  
})
// 組件內(nèi)
directives: {  
    focus: {  
        // 指令的定義  
        inserted: function (el) {  
            el.focus()  
        }  
    }  
}
<input v-focus>

自定義指令中可以使用的鉤子函數(shù):

一個(gè)指令定義對(duì)象可以提供如下幾個(gè)鉤子函數(shù) (均為可選):

`bind`:只調(diào)用一次,指令第一次綁定到元素時(shí)調(diào)用。在這里可以進(jìn)行一次性的初始化設(shè)置。

`inserted`:被綁定元素插入父節(jié)點(diǎn)時(shí)調(diào)用 (僅保證父節(jié)點(diǎn)存在,但不一定已被插入文檔中)。

`update`:所在組件的 VNode 更新時(shí)調(diào)用,**但是可能發(fā)生在其子 VNode 更新之前**。

指令的值可能發(fā)生了改變,也可能沒有。但是你可以通過比較更新前后的值來(lái)忽略不必要的模板

更新 (詳細(xì)的鉤子函數(shù)參數(shù)見下)。

`componentUpdated`:指令所在組件的 VNode **及其子 VNode** 全部更新后調(diào)用。

`unbind`:只調(diào)用一次,指令與元素解綁時(shí)調(diào)用。

鉤子函數(shù)的參數(shù):

`el`:指令所綁定的元素,可以用來(lái)直接操作 DOM。
`binding`:一個(gè)對(duì)象,包含以下 property:
    `name`:指令名,不包括 `v-` 前綴
    `value`:指令的綁定值,例如:`v-my-directive="1 + 1"` 中,綁定值為 `2`.
    `oldValue`:指令綁定的前一個(gè)值,僅在 `update` 和 `componentUpdated` 鉤子中可用。
    無(wú)論值是否改變都可用。
    `expression`:字符串形式的指令表達(dá)式。例如 `v-my-directive="1 + 1"` 中,
    表達(dá)式為 `"1 + 1"`。
    `arg`:傳給指令的參數(shù),可選。例如 `v-my-directive:foo` 中,參數(shù)為 `"foo"`。
    `modifiers`:一個(gè)包含修飾符的對(duì)象。例如:`v-my-directive.foo.bar` 中,修飾符對(duì)象為 `{ foo: true, bar: true }`。
`vnode`:Vue 編譯生成的虛擬節(jié)點(diǎn)。
`oldVnode`:上一個(gè)虛擬節(jié)點(diǎn),僅在 `update` 和 `componentUpdated` 鉤子中可用。

eg:

<div id="hook-arguments-example" v-demo:foo.a.b="message"></div>
Vue.directive('demo', {  
    bind: function (el, binding, vnode) {  
        var s = JSON.stringify  
        el.innerHTML =  
            'name: ' + s(binding.name) + '<br>' +  
            'value: ' + s(binding.value) + '<br>' +  
            'expression: ' + s(binding.expression) + '<br>' +  
            'argument: ' + s(binding.arg) + '<br>' +  
            'modifiers: ' + s(binding.modifiers) + '<br>' +  
            'vnode keys: ' + Object.keys(vnode).join(', ')  
    }  
})  
new Vue({  
    el: '#hook-arguments-example',  
    data: {  
        message: 'hello!'  
    }  
})

動(dòng)態(tài)指令:

指令的參數(shù)可以是動(dòng)態(tài)的。例如,在 v-mydirective:[argument]="value" 中,argument 參數(shù)可以根據(jù)組件實(shí)例數(shù)據(jù)進(jìn)行更新!這使得自定義指令可以在應(yīng)用中被靈活使用;

源碼解析

模板解析階段

編譯模板解析每個(gè)標(biāo)簽,會(huì)把標(biāo)簽上的屬性解析到一個(gè)對(duì)象的attrs屬性上,解析到閉合標(biāo)簽之后,會(huì)調(diào)用閉合標(biāo)簽的回調(diào)方法,方法中會(huì)針對(duì)屬性進(jìn)行處理,先處理v-bind,v-on,再處理自定義指令,會(huì)把自定義指令處理之后放在抽象語(yǔ)法樹的directives屬性上;

抽象語(yǔ)法樹生成render函數(shù)階段

解析抽象語(yǔ)法樹生成render函數(shù),directives指令會(huì)被作為render函數(shù)的屬性參數(shù);

render函數(shù)生成虛擬dom階段

執(zhí)行render函數(shù),把自定義指令屬性掛載到虛擬節(jié)點(diǎn)的data下的directives上

生成真實(shí)dom階段

creatElem創(chuàng)建真實(shí)dom的函數(shù)內(nèi)部在創(chuàng)建完真實(shí)dom之后,會(huì)去調(diào)用invokeCreateHooks方法執(zhí)行create相關(guān)的鉤子函數(shù),create函數(shù)內(nèi)部就會(huì)執(zhí)行_update方法;下面進(jìn)行解析_update方法;

// 源碼位置: src/core/vdom/modules/directives.js
export default {
  create: updateDirectives,
  update: updateDirectives,
  destroy: function unbindDirectives (vnode: VNodeWithData) {
    updateDirectives(vnode, emptyNode)
  }
}
function updateDirectives (oldVnode: VNodeWithData, vnode: VNodeWithData) {
  if (oldVnode.data.directives || vnode.data.directives) {
    _update(oldVnode, vnode)
  }
}
function _update (oldVnode, vnode) {
  // 舊節(jié)點(diǎn)不存在就表示是新創(chuàng)建的
  const isCreate = oldVnode === emptyNode
  // 新節(jié)點(diǎn)不存在表示是需要?jiǎng)h除的
  const isDestroy = vnode === emptyNode
  // 舊節(jié)點(diǎn)中的指令集合
  const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context)
  // 新節(jié)點(diǎn)中的指令集合
  const newDirs = normalizeDirectives(vnode.data.directives, vnode.context)
  // 保存需要執(zhí)行inserted鉤子的指令
  const dirsWithInsert = []
  // 保存需要執(zhí)行update鉤子的指令
  const dirsWithPostpatch = []
  let key, oldDir, dir
  // 遍歷新節(jié)點(diǎn)的指令
  for (key in newDirs) {
    // 獲取到舊節(jié)點(diǎn)中對(duì)應(yīng)的指令
    oldDir = oldDirs[key]
    dir = newDirs[key]
    // 如果舊節(jié)點(diǎn)中的指令不存在 表示是新添加的,通過bind進(jìn)行綁定
    if (!oldDir) {
      // new directive, bind
      callHook(dir, 'bind', vnode, oldVnode)
      // 如有inserted就進(jìn)行添加
      if (dir.def && dir.def.inserted) {
        dirsWithInsert.push(dir)
      }
    } else { // 如果舊節(jié)點(diǎn)中的指令存在 表示是需要更新的,執(zhí)行update
      // existing directive, update
      dir.oldValue = oldDir.value
      dir.oldArg = oldDir.arg
      callHook(dir, 'update', vnode, oldVnode)
      if (dir.def && dir.def.componentUpdated) {
        dirsWithPostpatch.push(dir)
      }
    }
  }
  // 如果dirsWithInsert有值
  if (dirsWithInsert.length) {
    // 創(chuàng)建一個(gè)函數(shù),函數(shù)內(nèi)部遍歷dirsWithInsert并且執(zhí)行inserted鉤子
    const callInsert = () => {
      for (let i = 0; i < dirsWithInsert.length; i++) {
        callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode)
      }
    }
    // 如果是新建的,就和insert鉤子進(jìn)行合并執(zhí)行
    if (isCreate) {
      mergeVNodeHook(vnode, 'insert', callInsert)
    } else {
      // 否則執(zhí)行指令中的inserted鉤子
      callInsert()
    }
  }
  // dirsWithPostpatch有值 就合并componentUpdated和postpatch鉤子在dom更新的時(shí)候執(zhí)行
  if (dirsWithPostpatch.length) {
    mergeVNodeHook(vnode, 'postpatch', () => {
      for (let i = 0; i < dirsWithPostpatch.length; i++) {
        callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode)
      }
    })
  }
  // 如果不是新建的
  if (!isCreate) {
    // 遍歷舊節(jié)點(diǎn)中的指令
    for (key in oldDirs) {
      // 如果新節(jié)點(diǎn)中不存在此指令,表示是要解綁的,調(diào)用unbind鉤子
      if (!newDirs[key]) {
        // no longer present, unbind
        callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy)
      }
    }
  }
}

指令的創(chuàng)建,更新和銷毀都是同一個(gè)函數(shù)updateDirectives,而updateDirectives函數(shù)內(nèi)部,判斷就節(jié)點(diǎn)上的指令或新節(jié)點(diǎn)上的指令存在就執(zhí)行_update方法;

export default {
  create: updateDirectives,
  update: updateDirectives,
  destroy: function unbindDirectives (vnode: VNodeWithData) {
    updateDirectives(vnode, emptyNode)
  }
}
function updateDirectives (oldVnode: VNodeWithData, vnode: VNodeWithData) {
  // 舊節(jié)點(diǎn)的指令或新節(jié)點(diǎn)的指令存在
  if (oldVnode.data.directives || vnode.data.directives) {
    _update(oldVnode, vnode)
  }
}

_update函數(shù)內(nèi)部首先聲明了6個(gè)變量;

// 舊節(jié)點(diǎn)不存在就表示是新創(chuàng)建的
const isCreate = oldVnode === emptyNode
// 新節(jié)點(diǎn)不存在表示是需要?jiǎng)h除的
const isDestroy = vnode === emptyNode
// 舊節(jié)點(diǎn)中的指令集合
const oldDirs = normalizeDirectives(oldVnode.data.directives, oldVnode.context)
// 新節(jié)點(diǎn)中的指令集合
const newDirs = normalizeDirectives(vnode.data.directives, vnode.context)
// 保存需要執(zhí)行inserted鉤子的指令
const dirsWithInsert = []
// 保存需要執(zhí)行update鉤子的指令
const dirsWithPostpatch = []

接著遍歷新節(jié)點(diǎn)中的指令,并且保存新舊節(jié)點(diǎn)中對(duì)應(yīng)的指令的值;

let key, oldDir, dir
  // 遍歷新節(jié)點(diǎn)的指令
  for (key in newDirs) {
    // 獲取到舊節(jié)點(diǎn)中對(duì)應(yīng)的指令
    oldDir = oldDirs[key]
    dir = newDirs[key]

如果舊節(jié)點(diǎn)中的此指令不存在,表示是新添加的,執(zhí)行bind鉤子進(jìn)行綁定,并且判斷是否傳遞了inserted鉤子,如果傳遞了就把當(dāng)前指令存到dirsWithInsert中;

// 如果舊節(jié)點(diǎn)中的指令不存在 表示是新添加的,通過bind進(jìn)行綁定
if (!oldDir) {
  // new directive, bind
  callHook(dir, 'bind', vnode, oldVnode)
  // 如有inserted就進(jìn)行添加
  if (dir.def && dir.def.inserted) {
    dirsWithInsert.push(dir)
  }
}

如果舊節(jié)點(diǎn)中的此指令存在,表示是需要更新,把舊指令的參數(shù)和值保存到新指令對(duì)象上,并且執(zhí)行update鉤子,判斷是否傳遞了componentUpdated鉤子,傳遞了就保存到dirsWithPostpatch中;

else { // 如果舊節(jié)點(diǎn)中的指令存在 表示是需要更新的,執(zhí)行update
  // existing directive, update
  dir.oldValue = oldDir.value
  dir.oldArg = oldDir.arg
  callHook(dir, 'update', vnode, oldVnode)
  if (dir.def && dir.def.componentUpdated) {
    dirsWithPostpatch.push(dir)
  }
}

如果dirsWithInsert有值,就創(chuàng)建一個(gè)函數(shù),函數(shù)內(nèi)部遍歷這個(gè)dirsWithInsert,通過callback調(diào)用每一個(gè)指令的inserted鉤子;判斷當(dāng)前節(jié)點(diǎn)是否是新建的,是新創(chuàng)建的就和insert鉤子進(jìn)行合并執(zhí)行,如果不是新創(chuàng)建的直接執(zhí)行inserted鉤子;(為什么需要合并鉤子?是因?yàn)閕nserted鉤子的執(zhí)行時(shí)機(jī)是dom已經(jīng)插入到頁(yè)面中,而新創(chuàng)建的節(jié)點(diǎn)被插入到頁(yè)面中就會(huì)執(zhí)行insert鉤子,因此把它們進(jìn)行合并,再插入的時(shí)候再去執(zhí)行)

// 如果dirsWithInsert有值
if (dirsWithInsert.length) {
    // 創(chuàng)建一個(gè)函數(shù),函數(shù)內(nèi)部遍歷dirsWithInsert并且執(zhí)行inserted鉤子
    const callInsert = () => {
      for (let i = 0; i < dirsWithInsert.length; i++) {
        callHook(dirsWithInsert[i], 'inserted', vnode, oldVnode)
      }
    }
    // 如果是新建的,就和insert鉤子進(jìn)行合并執(zhí)行
    if (isCreate) {
      mergeVNodeHook(vnode, 'insert', callInsert)
    } else {
      // 否則執(zhí)行指令中的inserted鉤子
      callInsert()
    }
}

如果dirsWithPostpatch有值,就進(jìn)行遍歷執(zhí)行componentUpdated鉤子;

// dirsWithPostpatch有值 就合并componentUpdated和postpatch鉤子在dom更新的時(shí)候執(zhí)行
if (dirsWithPostpatch.length) {
    mergeVNodeHook(vnode, 'postpatch', () => {
      for (let i = 0; i < dirsWithPostpatch.length; i++) {
        callHook(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode)
      }
    })
}

如果不是新創(chuàng)建的,就遍歷舊節(jié)點(diǎn)的指令,判斷新節(jié)點(diǎn)上是否有此指令,沒有就表示需要解綁,那么就執(zhí)行unbind鉤子;

// 如果不是新建的
if (!isCreate) {
    // 遍歷舊節(jié)點(diǎn)中的指令
    for (key in oldDirs) {
      // 如果新節(jié)點(diǎn)中不存在此指令,表示是要解綁的,調(diào)用unbind鉤子
      if (!newDirs[key]) {
        // no longer present, unbind
        callHook(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy)
      }
    }
}

normalizeDirectives函數(shù),把指令的值進(jìn)行格式化處理;

const emptyModifiers = Object.create(null)
/**
 * 獲取到鉤子的值,并且進(jìn)行統(tǒng)一的格式化操作
 * @param {*} dirs 
 * @param {*} vm 
 * @returns 
   格式化之后的結(jié)果
   {
 *  v-focus: {
 *    name: 'focus', // 指令名稱
 *    value: '', // 指令值
 *    arg: '', // 參數(shù)
 *    modifiers: {}, // 修飾符
 *    def: { inserted: fn } // 回調(diào)
 *  }
 * }
 */
function normalizeDirectives (
  dirs: ?Array<VNodeDirective>,
  vm: Component
): { [key: string]: VNodeDirective } {
  // 創(chuàng)建一個(gè)對(duì)象
  const res = Object.create(null)
  // 指令不存在直接返回
  if (!dirs) {
    // $flow-disable-line
    return res
  }
  let i, dir
  // 遍歷指令
  for (i = 0; i < dirs.length; i++) {
    dir = dirs[i]
    // 如果修飾符屬性不存在就創(chuàng)建一個(gè)空的對(duì)象
    if (!dir.modifiers) {
      // $flow-disable-line
      dir.modifiers = emptyModifiers
    }
    // 添加到對(duì)象上
    res[getRawDirName(dir)] = dir
    // 找出指令的值
    dir.def = resolveAsset(vm.$options, 'directives', dir.name, true)
  }
  // $flow-disable-line
  return res
}
function getRawDirName (dir: VNodeDirective): string {
  return dir.rawName || `${dir.name}.${Object.keys(dir.modifiers || {}).join('.')}`
}

callHook函數(shù),內(nèi)部直接執(zhí)行對(duì)應(yīng)的hook函數(shù);

function callHook (dir, hook, vnode, oldVnode, isDestroy) {
  const fn = dir.def && dir.def[hook]
  if (fn) {
    try {
      fn(vnode.elm, dir, vnode, oldVnode, isDestroy)
    } catch (e) {
      handleError(e, vnode.context, `directive ${dir.name} ${hook} hook`)
    }
  }
}

小結(jié):

  • _update函數(shù)內(nèi)部,主要通過新舊的判斷是新建還是刪除節(jié)點(diǎn),并且通過一個(gè)方法把指令進(jìn)行格式化處理得到新舊節(jié)點(diǎn)上的新舊指令;
  • 遍歷新指令集合如果舊指令集合中不存在此指令,表示新建,就執(zhí)行bind鉤子,并且把指令存儲(chǔ)到插入指令的數(shù)組中;如果舊指令集合中存在,表示更新,執(zhí)行update鉤子,并且把此指令存入到更新的數(shù)組中;
  • 接著判斷插入指令數(shù)組如果有值,如果當(dāng)前節(jié)點(diǎn)是新建的,那么就合并執(zhí)行insert和inserted鉤子;否則不是新建,直接執(zhí)行inserted鉤子
  • 判斷更新的數(shù)組有值,合并執(zhí)行postpatch和componentUpdated鉤子
  • 最后判斷如果不是新建的節(jié)點(diǎn),并且遍歷舊指令集合,如果在新指令中沒有找到此指令,表示是刪除的,執(zhí)行unbind鉤子;
  • 以上就完成了自定義指令中的各個(gè)鉤子的執(zhí)行,并且_update函數(shù)的執(zhí)行是在dom插入到文檔中之前執(zhí)行的,并且在子組件創(chuàng)建完成之后;

總結(jié)

自定義指令是在模板編譯節(jié)點(diǎn)進(jìn)行解析收集自定義指令屬性的,自定義指令在此階段都是作為屬性被添加到ast的directives上;在render函數(shù)生成虛擬節(jié)點(diǎn)的時(shí)候被作為虛擬節(jié)點(diǎn)的data下的directives屬性;在創(chuàng)建真實(shí)dom之后,就會(huì)執(zhí)行自定義指令的各個(gè)鉤子方法,通過新舊節(jié)點(diǎn)來(lái)判斷是新建的還是刪除的還是更新的(舊虛擬dom不存在表示新建,新虛擬dom不存在表示刪除),如果是新建的并且新的指令集合中存在,舊的指令集合中不存在的指令就執(zhí)行bind方法,表示新建并且把當(dāng)前指令添加到插入數(shù)組中;如果舊指令集合中存在此指令,表示更新,執(zhí)行update方法并且插入到更新數(shù)組中;如果插入數(shù)組有值,并且是新增的節(jié)點(diǎn)就合并執(zhí)行insert和inserted方法;如果不是新增就執(zhí)行inserted方法;如果更新數(shù)組有值,直接合并執(zhí)行postpatch和componentUpdated方法;最后遍歷舊指令集合如果舊的存在新的不存在那么表示刪除,直接調(diào)用unbind方法;(自定義指令其實(shí)就是在對(duì)應(yīng)的dom創(chuàng)建之后還未插入到文檔中之前,通過新舊虛擬節(jié)點(diǎn)和新舊指令判斷是新建的還是更新的還是刪除的,從而執(zhí)行不同的鉤子函數(shù))

到此這篇關(guān)于Vue2源碼解析之自定義指令的文章就介紹到這了,更多相關(guān)Vue2自定義指令內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • VUE項(xiàng)目中引入vue-router的詳細(xì)過程

    VUE項(xiàng)目中引入vue-router的詳細(xì)過程

    vue-router 也叫 vue 路由,根據(jù)不同的路徑,來(lái)執(zhí)行不同的組件,這篇文章主要介紹了VUE項(xiàng)目中引入vue-router,需要的朋友可以參考下
    2023-05-05
  • Vue異步的處理原理分析

    Vue異步的處理原理分析

    Vue通過異步隊(duì)列批量處理數(shù)據(jù)變化與DOM更新,減少性能損耗;使用$nextTick獲取更新后的DOM;異步請(qǐng)求需處理加載狀態(tài);生命周期鉤子內(nèi)可包含異步操作;核心原理為依賴收集→去重→微任務(wù)延遲→批量更新,確保高效響應(yīng)
    2025-08-08
  • 在vue中更換字體,本地存儲(chǔ)字體非引用在線字體庫(kù)的方法

    在vue中更換字體,本地存儲(chǔ)字體非引用在線字體庫(kù)的方法

    今天小編就為大家分享一篇在vue中更換字體,本地存儲(chǔ)字體非引用在線字體庫(kù)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2018-09-09
  • Vue.2.0.5過渡效果使用技巧

    Vue.2.0.5過渡效果使用技巧

    這篇文章主要介紹了Vue.2.0.5過渡效果使用技巧,實(shí)例分析了Vue.2.0.5過渡效果的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下。
    2017-03-03
  • vue3的內(nèi)置組件匯總

    vue3的內(nèi)置組件匯總

    本文主要介紹了vue3的內(nèi)置組件匯總,詳細(xì)的介紹了Fragment,Teleport,Suspense三個(gè)組件的使用,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-01-01
  • vue填坑之webpack run build 靜態(tài)資源找不到的解決方法

    vue填坑之webpack run build 靜態(tài)資源找不到的解決方法

    今天小編就為大家分享一篇vue填坑之webpack run build 靜態(tài)資源找不到的解決方法。具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2018-09-09
  • 如何在vue3.0+中使用tinymce及實(shí)現(xiàn)多圖上傳文件上傳公式編輯功能

    如何在vue3.0+中使用tinymce及實(shí)現(xiàn)多圖上傳文件上傳公式編輯功能

    本文給大家分享tinymce編輯器如何在vue3.0+中使用tinymce及實(shí)現(xiàn)多圖上傳文件上傳公式編輯功能,tinymce安裝方法文中也給大家詳細(xì)介紹了,對(duì)vue tinymce實(shí)現(xiàn)上傳公式編輯相關(guān)知識(shí)感興趣的朋友跟隨小編一起學(xué)習(xí)下吧
    2021-05-05
  • 關(guān)于vue2使用swiper4的踩坑記錄

    關(guān)于vue2使用swiper4的踩坑記錄

    最近寫vue的一個(gè)練手項(xiàng)目需要在里面實(shí)現(xiàn)一個(gè)輪播圖,想到去用第三方插件,百度了一輪,發(fā)現(xiàn)大部分都是swiper這個(gè)插件,這篇文章主要給大家介紹了關(guān)于vue2使用swiper4踩坑的相關(guān)資料,需要的朋友可以參考下
    2022-01-01
  • vue路由$router.push()使用query傳參的實(shí)際開發(fā)使用

    vue路由$router.push()使用query傳參的實(shí)際開發(fā)使用

    在vue項(xiàng)目中我們用函數(shù)式編程this.$router.push跳轉(zhuǎn),用query傳遞一個(gè)對(duì)象時(shí)要把這個(gè)對(duì)象先轉(zhuǎn)化為字符串,然后在接收的時(shí)候要轉(zhuǎn)化為對(duì)象,下面這篇文章主要給大家介紹了關(guān)于vue路由$router.push()使用query傳參的實(shí)際開發(fā)使用,需要的朋友可以參考下
    2022-11-11
  • Vue.js 踩坑記之雙向綁定

    Vue.js 踩坑記之雙向綁定

    這篇文章給大家?guī)?lái)了Vue.js 踩坑記之雙向綁定問題,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友跟隨腳本之家小編一起學(xué)習(xí)吧
    2018-05-05

最新評(píng)論

文昌市| 遂昌县| 水城县| 乾安县| 涿州市| 昌江| 丹东市| 根河市| 章丘市| 绥中县| 河南省| 安顺市| 吉首市| 张家界市| 太湖县| 庆云县| 秭归县| 吴川市| 资源县| 赤城县| 孝感市| 石屏县| 赤壁市| 财经| 金乡县| 嵊泗县| 杨浦区| 勃利县| 丰都县| SHOW| 唐山市| 泰和县| 改则县| 舞阳县| 南投县| 滨州市| 吉木乃县| 神池县| 南汇区| 镇赉县| 通城县|