I searched many internet sites but didn't find useful snippets for my problem resolution.
I wanted to achieve simple data passing from input field value in Vue component to Vue root element with a method for data fetching,
e.g., simply when I press submit button, the browser alerts me with a msg
message instead of undefined
.
With Vue technology, I absolutely don't understand how to do this. I spend almost a day trying to understand this. Actually, I don't get how Vue even works with these roots and components even after reading basics nth times. Is there any simple explanation?
Please help!
<div id="form">
<button v-on:click="submitBtn">Save</button>
<custom-form></custom-form>
</div>
<script>
var testApp = Vue.createApp ({
methods: {
submitBtn: function(){
alert(submit.test)
}
}
})
testComponent.component('custom-form', {
template: `
<label>test<input type="text" v-model=value :value=this.test></label>
` ,
data: function() {
return {
test: 'msg'
}
},
methods: {
test: function() {
return this.test
}
}
})
const vm = testApp.mount('#form')
</script>