as shown in the figure, I get the data in vuex in created. I can get it as soon as I enter the page, but I can"t get the data after the page is refreshed
as shown in the figure, I get the data in vuex in created. I can get it as soon as I enter the page, but I can"t get the data after the page is refreshed
page refreshes. The data in the discussion group 163958730
store
is the original storage component state and is not used for local data storage after refreshing
can be solved through local storage.
Local storage can be localStorage/sessionStorage
or cookie
.
you can think of it as js cached data; for example:
let arr = [];
// [1]
//
can be solved through sessionStorage or localStorage
const state = {phone:localStorage.getItem('phone')||""}
can be saved with sessionStorage in your store.js, and you can get
when refreshing.Previous: Ant-design tree-select problem
Next: Can't Mini Program get the value of the internal object in data in post mode?
when namespaced is not used, actions is registered globally by default, but after use, actions will become under the module, but I don t want to do this. I also want it to be global. My namespace:true is just for the convenience that I introduce state, ...
there are more than 10 methods for methods in one of my .vue files, and this page looks messy. is it because my componentization is not thorough enough; is there any way to make the file more concise ...
I want a variable in the drop-down box v-model data, and the default value of this variable is the constant defined in state, but what if it doesn t change with the value in state? reference: https: codeshelper.com q 10. The value of computed canno...
[vue] Why use vuex instead of window.obj to maintain global instance properties and methods? ...
problem description I currently have a parent component, which has more than 20 child components A1, a2, and so on, and I want them to update their balances. What s the best way to deal with it. the environmental background of the problems and what...
state.js state:{ data:{} } mutation.js type.data (state, arg) { return state.data = arg } action.js commit(types.data, {a: 111, b: 222}) getters.js export const data = (state) => { return state.data } is called in the methods method o...
the code is as follows: import headerVue from ". components header.vue"; import bodyVue from ". components body.vue"; import footerVue from ". components footer.vue"; import connector from ". components connector.js&q...
model: there are two ways: 1. this.getData().then(data => { data; }) Mode 1 is to save a state in vuex , and in many cases, I first call updateData to make sure that data in state is up-to-date. method 2 does not need state , but ...