How to set the priority of Vue2 directives?
欧阳克
欧阳克 2017-07-05 10:54:52
0
1
1276

About the priority issue of Vue2 instructions

After reading the relevant information, I found that priority needs to be set when registering the command. The larger the value, the higher the priority.

html

<p id="app">
<span v-a="'abc'" v-b="'efg'"></span>  
</p>

js

Vue.directive('a', {
    priority: 990,
    bind: function () {
      alert('a')
  }
})
Vue.directive('b', {
    priority: 1000,
    bind: function () {
      alert('b')
  }
})

new Vue({
    el: "#app"
})

Expected effect

Execute alert('b') first, then alert('a');

Actual effect

Execute alert('a') first, then alert('b');

Please tell me how to set it up so that the 'v-b' command can be executed first and then the 'v-a' command

---------Separating line----------
Knownpriority is abandoned, then does it represent the execution of two customized instructions? The order can only be executed in the order of front and back?

欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all(1)
漂亮男人

In Vue2, the priority attribute in custom directives has been abandoned
For details, see: https://cn.vuejs.org/v2/guide... Custom directives - simplified

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template