Last active
March 1, 2016 22:44
-
-
Save airtonix/8cad6c7406d4936ae96e to your computer and use it in GitHub Desktop.
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 v-on:click="click">Click Me!</div> | |
</template> | |
<script> | |
export default { | |
data () { | |
return { | |
foo: 'bar' | |
} | |
}, | |
props: { | |
clickFn: { | |
default: null | |
} | |
}, | |
methods: { | |
click () { | |
if (!this.clickFn || !(typeof this.clickFn === 'function')) { | |
// default click action | |
} else { | |
this.clickFn.call(this); | |
// or | |
this.clickFn.call(this, 'an argument for clickFn', 'and another'); | |
// or even just something simple: | |
this.clickFn(); | |
} | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment