Skip to content

Instantly share code, notes, and snippets.

@airtonix
Last active March 1, 2016 22:44
Show Gist options
  • Save airtonix/8cad6c7406d4936ae96e to your computer and use it in GitHub Desktop.
Save airtonix/8cad6c7406d4936ae96e to your computer and use it in GitHub Desktop.
<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