Vue.directive()

Vue.directive( id, [definition] )

  • Arguments:

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

    Register or retrieve a global directive.

    // 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
2016-09-25 05:48:21
Comments
Leave a Comment

Please login to continue.