Skip to content

Instantly share code, notes, and snippets.

@boonyasukd
Created July 26, 2017 11:30
Show Gist options
  • Save boonyasukd/918e760e722948a9faa2d593b75b0ed9 to your computer and use it in GitHub Desktop.
Save boonyasukd/918e760e722948a9faa2d593b75b0ed9 to your computer and use it in GitHub Desktop.
Assignment 10
<template>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
<h1>Directives Exercise</h1>
<div v-my-on:click="doAlert">I dare you to try clicking this text!</div>
<input v-my-on:keyup="doInputAlert">
</div>
</div>
</div>
</template>
<script>
export default {
methods: {
doAlert() {
alert('something happened!');
},
doInputAlert() {
alert('something typed into <input>!');
}
},
directives: {
'my-on': {
bind(el, binding, vnode) {
switch(binding.arg) {
case 'click':
el.onclick = binding.value;
break;
case 'keyup':
el.onkeyup = binding.value;
break;
}
},
},
},
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment