1
People are creating a simple Directive and wanted to know how to put a value if the binding.value
for undefined
in a simpler way, much like the Vue Component in which you can set the defalut value?
Example:
Vue.directive('color', {
bind: function (el, binding) {
var prop = binding.value,
color = prop.color
if(color == undefined) color = '#FFFFFF'
el.style.backgroundColor = color
}
})