Forked from laracasts/vue-custom-input-component-exercise.js
          
        
    
          Created
          August 31, 2017 16:48 
        
      - 
      
- 
        Save TonyDalian/f0861a49c9e8f365be77cbf7ece37457 to your computer and use it in GitHub Desktop. 
    vuecasts.com - Custom Input Components exercise.
  
        
  
    
      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
    
  
  
    
  | 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