Vue.js 1.0.0 RC2 发布,轻量级 JavaScript 框架
Custom directive API improvement:Custom directives can now provide a params Array, and
the Vue compiler will automatically extract these attributes on the
element that the directive is bound to. The old undocumented this.param() directive instance method has been deprecated.
Example:
Vue.directive('example', {
params: ['a'], bind: function () { console.log(this.params.a) // -> "hi"
}
})
This API also supports dynamic attributes. The this.params value is automatically kept up-to-date. In addition, you can specify a callback when the value has changed:
Vue.directive('example', {
params: ['a'],
paramWatchers: { a: function (val, oldVal) { console.log('a changed!')
}
}
})
页:
[1]