Skip to content

Instantly share code, notes, and snippets.

@johanvergeer
Last active June 19, 2019 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johanvergeer/f18b4f9e9785496326c082b78c76ef23 to your computer and use it in GitHub Desktop.
Save johanvergeer/f18b4f9e9785496326c082b78c76ef23 to your computer and use it in GitHub Desktop.
// Create a component, which is global and can be used anywhere
// in the application
const Hello = Vue.component(
'Hello', // Name of the component
{ templdate: '<span>Hello</span>' } // Options object, which contains a template
)
new Vue({
template: '<div><Hello/> there</div>', // Hardcoded 'Hello' is replated with the component
el: '#app'
});
new Vue({
template: '<div>Hello there</div>',
el: '#app'
});
// This is where the html template for the component is defined
// Requireda
<template>
<span class="hello">Hello there</span>
</template>
// This is where the Javascript for the component is defined
// Required
<script>
export default { name: 'Hello' }
</script>
// This is where the css classes fot the component are defined
// Optional
<style>
.hello {
color: white;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment