Skip to content

Instantly share code, notes, and snippets.

@shunwitter
Created October 25, 2016 00:59
Show Gist options
  • Save shunwitter/91666aaf32ad1819d82b1c2444ffa415 to your computer and use it in GitHub Desktop.
Save shunwitter/91666aaf32ad1819d82b1c2444ffa415 to your computer and use it in GitHub Desktop.
Vuejs Simple Convention
<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