I want to understand how Vue works. What I am trying approach is simply to receive number '1' with method in Vue. Code execution gives me 'undefined'. Why?
<div id="form">
<button v-on:click="submitProduct">Save</button>
</div>
<script>
var someForm = Vue.createApp ({
methods: {
submitBtn: function(){
someForm.showdata
},
showData: function(){
return 1
}
}
})
</script>
CodePudding user response:
Try to assign the returned data to a variable then show it using alert or console.log a,d use this
instead of someForm
:
var someForm = Vue.createApp ({
methods: {
submitBtn: function(){
let data= this.showData();
alert(data);
},
showData: function(){
return 1
}
}
})