Created
October 25, 2016 00:59
-
-
Save shunwitter/91666aaf32ad1819d82b1c2444ffa415 to your computer and use it in GitHub Desktop.
Vuejs Simple Convention
This file contains hidden or 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 lang="pug"> | |
h1 {{title}} | |
p {{body}} | |
</template> | |
<script> | |
export default { | |
// Convention: Component name is camel case | |
name: 'MyComponentA', | |
props: {}, | |
data: function() { | |
return { | |
title: "", | |
body: "" | |
} | |
}, | |
created: function() { | |
// Convention: 'component name' + 'DataLoaded' | |
eventHub.$on('MyComponentADataLoaded', this.update) | |
}, | |
methods: { | |
update: function(newData) { | |
this.title = newData.title | |
this.body = newData.body | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment