s12e161 arguments to custom directives

This commit is contained in:
Tyrel Souza 2018-04-20 15:36:35 -04:00
parent 21a83d215c
commit 24bec745d1
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
2 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,7 @@
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<h1>Custom Directives</h1>
<p v-highlight:background='"red"'>Color This</p>
<p v-highlight='"red"'>Color This</p>
</div>
</div>

View File

@ -3,7 +3,12 @@ import App from './App.vue'
Vue.directive('highlight', {
bind(el, binding, vnode){
el.style.backgroundColor = binding.value;
// el.style.backgroundColor = binding.value;
if (binding.arg == "background"){
el.style.backgroundColor = binding.value;
} else {
el.style.color = binding.value;
}
}
})