Vue.directive()

Vue.directive( id, [definition] )

  • Arguments:

    • {String} id
    • {Function | Object} [definition]
  • Usage:

    Register or retrieve a global directive.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    // register
    Vue.directive('my-directive', {
      bind: function () {},
      update: function () {},
      unbind: function () {}
    })
     
    // register (simple function directive)
    Vue.directive('my-directive', function () {
      // this will be called as `update`
    })
     
    // getter, return the directive definition if registered
    var myDirective = Vue.directive('my-directive')
  • See also: Custom Directives

doc_VueJS
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.