I'm learning vue. js .I'm trying to make simple form by using vue.js but I got above error while making a form. I tried but unable to fix the problem. Please help me.
<div id="app">
<form name="form" @submit.prevent="handleLogin">
<input
v-model="fiscal_year"
v-validate="'required'"
type="text"
class="form-control"
name="fiscal_year"
/>
<button class="btn btn-primary btn-block" :disabled="loading">
<span v-show="loading" class="spinner-border spinner-border-sm"></span>
<span>Submit</span>
</button>
</form>
<script>
var app = new Vue({
el: '#app',
data: {
fiscal_year: 2000,
loading: false,
},
mount:function(){},
methods: {
handleLogin(){
console.log('handle login');
this.loading = true;
}
}
})
</script>
v-model="fiscal_year"requires a property calledfiscal_yearon your Vue instance/component. Have you defined such a property in your JavaScript code? You'll need to post that code for us to help you further. - skirtle.vuefile. Could you clarify whether the code above is in a.vuefile or is it in a normal HTML file? To be clear, you shouldn't be creating anew Vueinside a.vuefile, you should just be exporting the component definition. A.vuewould then need to be built using Webpack. I strongly suggest you use the Vue CLI if you aren't already, it'll show you how it's done. The code as posted is missing a closing</div>tag before the<script>. Is this really the exact code you are trying to run? - skirtle