I am attempting to set and get a username, password, and an authentication boolean from the global vuex state and conditionally render some elements in a navbar. Here is the login component which should pass the data:
<template>
<div class="login" id="login">
<b-form-input
id="inputfield"
v-model="username"
type="text"
placeholder="username">
</b-form-input>
<b-form-input
id="inputfield"
type="password"
v-model="password"
placeholder="password">
</b-form-input>
<b-button @click="login()" id = "inputfield" variant="outline-success">
Login
</b-button>
</div>
</template>
<script>
export default {
name: 'login',
computed: {
username () {
return this.$store.state.username
},
password () {
return this.$store.state.password
},
loggedIn () {
return this.$store.state.loggedIn
}
},
methods: {
login () {
this.$store.dispatch('login', {
username: this.username,
password: this.password,
isAuthed: true // just to test
})
}
}
}
</script>
However, when i enter anything in the input fields, Vue throws a warning for that field(and the state will not update):
[Vue warn]: Computed property "username" was assigned to but it has no setter.