Open sethdorris opened 7 years ago
Um, that's exactly what it's doing? context.state
is sent to the browser to be used as the initial state for Vuex.
how do I get access to that in my component though, I'm not really understanding that piece
Okay, I understand now... but any idea why this button does not fire? if I fire up a jsFiddle it fires just like how I have it written, is there a server side render idiom i'm missing?
<template>
<div>
<div>Login</div>
<div>
<label for="reg-username">Username: </label>
<input type="text" id="reg-username" v-model="username"/>
<label for="reg-password">Password: </label>
<input type="password" id="reg-password" v-model="password"/>
<button id="submit-login" v-on:click="submit">LOGIN</button>
</div>
</div>
</template>
<script>
export default {
data() {
return {
username: '',
password: '',
}
},
asyncData({store}) {
console.log(store.state);
return store.state.username;
},
methods: {
submit: function (e) {
console.log("hihii")
console.log(data);
//Do some data validation for security
this.$http.post('/login', data, function (res) {
document.getElementById("submit-login").disabled = "true";
}).then(function (data) {
console.log(data)
})
}
}
}
</script>
Can you pass context data set on the server.js into a vuex store to initialize data?