vuex

VueJS: Best way to Cache http response data

孤街浪徒 提交于 2019-12-24 19:27:50
问题 I'm finding a best way to Cache http response data in VueJS , Now I use Vuex Store to my Blog. I want to cache all response data when it requested into server. Specifically, this is my blog: When I request data by router to blog detail with 1, 3, 4 , I have response data. How can I cache it and then I re-route to 1, 3, 4 in the same session , it not re-fetch data and get data cache to display? Now I use Vuex and I think it slow if has to store too many data. 回答1: Service Workers were built

Can't get state stored by Vuex in ~/plugins/axios.js

时间秒杀一切 提交于 2019-12-24 17:16:12
问题 I have problem to get token stored by Vuex in ~/plugins/axios.js. Hope your guys take a look for me please. My Vuex: ~/store/index.js export const state = () => ({ authUser: null, token: null }) export const mutations = { SET_USER: function (state, user) { state.authUser = user }, SET_TOKEN: function (state, token) { state.token = token instance.defaults.headers = { Authorization: 'Bearer ' + token } } } export const actions = { async nuxtServerInit ({ commit }, { req }) { ... }, async login

How to get states from a Vuex store from within a Vuetify list, VueJs

丶灬走出姿态 提交于 2019-12-24 16:41:14
问题 I have a Vue file that looks like so : import store from '@/store' export default{ name: 'myList', data: () => ({ show: true, listContent: [{ name: '1', icon: 'person', value: function () { return store.state.myStore.settings.one } }, { name: '2', icon: 'person', value: function () { return store.state.myStore.settings.two } }, { name: '3', icon: 'person', value: function () { return store.state.myStore.settings.three } } ] }) } The part that's not working is getting the 'value' from the

Update prop property when vuex store changes

南笙酒味 提交于 2019-12-24 14:28:05
问题 After a successful mutation to the vuex store ( state.posts.post.comments ) using this code, and using Vue.set so Vue can recognize the addition of an object property: store/modules/post.js const mutations = { [types.SET_POST_COMMENTS] (state, { comments, id }) { let post = state.posts.find(post => post._id === id) Vue.set(post, 'comments', comments) } } There is no update to the template or component. The prop post is non-reactive (I assume because even the watcher isn't triggered). I've

Triggering a route only after dispatch and commit completed in VueJS

六眼飞鱼酱① 提交于 2019-12-24 13:33:37
问题 I do have a form submit which takes email and password then pass them into an action in store called userSignIn SignIn.vue : onSubmit () { if (this.$refs.form.validate()) { const user = { email: this.email, password: this.password } this.$store.dispatch('userSignIn', user) .then(() => { this.$router.push('/') }).catch(err => { console.log(err) }) } } Within store, I do have a userSignIn action like this store.js actions: userSignIn ({commit, getters}, payload) { getters.Api.post(`user/signin`

Mutation does not update the store in VUEX

你说的曾经没有我的故事 提交于 2019-12-24 10:56:44
问题 Working with VUEX I am trying to update the store but I do not achieve it, I do not understand the reason since I only want to enter a numerical data without any complications.In the mutation enter messages by console and I receive them successfully but nothing happens in the state of cart. This is my code: Mutations.js export function shipping(state, cost) { state.cart.shipping = cost; console.log(cost); console.log('hello from mutation'); } Template: <input type="number" name="cost" :value=

Why v-model not working in input datetimepicker bootstrap? (Vue.JS 2)

[亡魂溺海] 提交于 2019-12-24 08:47:30
问题 My vue component, you can see this below : <template> <div> <div class="col-sm-2"> <div class="form-group"> <input v-model="fromDate" data-date-format="DD-MM-YYYY" title="DD-MM-YYYY" type="text" class="form-control" placeholder="Date" name="to_date" id="datetimepicker" required> </div> </div> <div class="col-sm-1"> <div class="form-group" style="text-align: center"> - </div> </div> <div class="col-sm-2"> <div class="form-group"> <input v-model="toDate" data-date-format="DD-MM-YYYY" title="DD

Vue Axios Dynamic URL

懵懂的女人 提交于 2019-12-24 07:57:24
问题 I would like to dynamically create the URL path for my axios post action in my vue.js application Here is the action: editProduct: function ({dispatch, commit}, payload) { axios .put('http://localhost:8081/product/5b5ca691e4f0d93c18e3f6d9', payload) .then(res => dispatch('loadProducts', res.data)) .catch(function (error) { console.log(error) }) .then(() => { commit('clearAddEditProduct') }) } I would like to replace the "5b5ca691e4f0d93c18e3f6d9" with whatever is in the state state: { // data

How to assign a timestamp to an array type doc item in Firebase

↘锁芯ラ 提交于 2019-12-24 07:37:55
问题 I am attempting to build a Vue.js app that enables dynamic pushing of items into an array in Cloud Firestore. The items are in the events array, contains various objects, one of which is a timestamp. See function below: let newDetails = this.newDetails let newImage = this.imageUrl let timestamp = moment(Date.now()).format('lll') let ref = db.collection('users').where('user_id', '==', firebase.auth().currentUser.uid) .get() .then(function (querySnapshot) { querySnapshot.forEach(function (doc)

How can I get value radio button when submit form on the vue component?

隐身守侯 提交于 2019-12-24 01:57:10
问题 I have two component My first component like this : <template> <div> ... <form-radio id="gender" name="gender" :data="genderData" v-model="gender">Gender</form-radio> ... <button type="submit" class="btn btn-primary" @click="submit">Submit</button> </div> </template> <script> export default { data() { return { gender: null, genderData: [ {id: 1, label: 'Men', value:1}, {id: 2, label: 'Women', value:2} ], } }, methods: { submit() { console.log('submit profile') console.log(this.gender) } } } <