I am attempting to read a variable from within the data object of a Vue component.
This is the Vue template I'm using
<template>
<section>
<b-field label="Engineer number">
<b-input type="number" v-model="engineer"></b-input>
</b-field>
<a class="button" @click="send_login">Login</a>
</section>
</template>
<script>
export default {
data() {
return {
engineer: '',
}
},
methods: {
send_login: () => {
console.log(this.engineer)
}
}
}
</script>
this.engineer always print undefined.
If I wasn't using the template files then this works
let login = new Vue({
el: '#loginApp',
data: {
username: '',
password: '',
engineer: '',
},
methods: {
login: () => {
console.log(login.engineer);
},
},
});
Any ideas on what I'm doing wrong?