Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tim-hub/3da17a9e4c9f1802ff5bc1c053757377 to your computer and use it in GitHub Desktop.
Save tim-hub/3da17a9e4c9f1802ff5bc1c053757377 to your computer and use it in GitHub Desktop.
vuecasts.com - Custom Input Components exercise.
Vue.component('coupon', {
props: ['code'],
template: `
<input type="text"
:value="code"
@input="updateCode($event.target.value)"
ref="input">
`,
methods: {
updateCode(code) {
// Atttach validation + sanitization here.
this.$emit('input', code);
}
}
});
new Vue({
el: '#app',
data: {
coupon: 'FREEBIE' // Maybe from DB or querystring.
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment