Created
July 26, 2017 11:30
-
-
Save boonyasukd/918e760e722948a9faa2d593b75b0ed9 to your computer and use it in GitHub Desktop.
Assignment 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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