v-model on Custom Components
| | |
| | | </template> |
| | | |
| | | <script>export default { |
| | | data() { |
| | | return { |
| | | activeOption: null, |
| | | }; |
| | | props: ['modelValue'], |
| | | emits: ['update:modelValue'], |
| | | // data() { |
| | | // return { |
| | | // activeOption: null, |
| | | // }; |
| | | // }, |
| | | computed: { |
| | | activeOption(){ |
| | | return this.modelValue; |
| | | } |
| | | }, |
| | | methods: { |
| | | activate(option) { |
| | | this.activeOption = option; |
| | | // this.activeOption = option; |
| | | this.$emit('update:modelValue', option); |
| | | } |
| | | } |
| | | |
| | |
| | | </div> |
| | | |
| | | <div class="form-control"> |
| | | <rating-control> |
| | | |
| | | </rating-control> |
| | | <rating-control v-model="rating"></rating-control> |
| | | </div> |
| | | |
| | | <div class="form-control"> |
| | |
| | | how: null, |
| | | confirm: false, |
| | | usernameValidity: 'pending', |
| | | rating: null, |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | |
| | | console.log('Checkbox: '); |
| | | console.log(this.interest); |
| | | console.log('Radio buttons: '); |
| | | console.log('- Radio buttons: '); |
| | | console.log(this.how); |
| | | this.interest = []; |
| | | this.how = null; |
| | | |
| | | console.log('Confirm'); |
| | | console.log('- Confirm:'); |
| | | console.log(this.confirm); |
| | | this.confirm = false; |
| | | |
| | | console.log('- Rating:'); |
| | | console.log(this.rating); |
| | | this.rating = null; |
| | | |
| | | }, |
| | | validateInput() { |
| | | if (this.userName === '') { |