Skip to content

Instantly share code, notes, and snippets.

@torbensky
Created May 31, 2020 15:20
Show Gist options
  • Save torbensky/0c77917f7f6f0fcb4fdfbc56fcfe0f68 to your computer and use it in GitHub Desktop.
Save torbensky/0c77917f7f6f0fcb4fdfbc56fcfe0f68 to your computer and use it in GitHub Desktop.
An example of how components are written using Vue.js
<div id="example">
<!-- using our custom component -->
<my-component></my-component>
</div>
<script>
// Define a new component
Vue.component('my-component', {
data: function () {
return {
count: 0
}
},
template: '<p>Click count: {{ count }}</p><button @click="count++">Add Click</button>'
})
// Setup root Vue instance
new Vue({ el: '#example' })
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment