vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

Custom Directive as browserify module not working #476

Closed noahmatisoff closed 8 years ago

noahmatisoff commented 8 years ago

I have a simple custom directive that I haven't added any functionality to: it's sitting in app/directives/currency.js:

module.exports = {
  update: function(newValue, oldValue) {
    console.log(newValue)
    console.log(oldValue)
  },
  bind: function() {

  },
  unbind: function() {

  }
}

And then in my Vue component, I have something like this:

module.exports = {
  template: require('./template.html'),
  directives: {
    currency: require('./directives/currency.js')
  }
}

But when I attach currency to a text input, nothing is being logged to the console. What is wrong with this?

noahmatisoff commented 8 years ago

Needed v-*, my bad.

FWSimon commented 8 years ago

hm i tried the same here, but it keep saying Failed to resolve directive: test2 and i have the v-test2

noahmatisoff commented 8 years ago

@FWSimon post code I'll let you know if I see anything that may be causing it.

FWSimon commented 8 years ago

Thanks @matisoffn i found out that it was because i needed to include the directive into my component :+1: Thanks

cnweibo commented 8 years ago

thanks, it save me 1 hour