The use of localStorage by vue does not take effect.

methods: {
applyFree () {

 localStorage.setItem("resultList", res.list);

}
}

I added local storage here why I didn"t save it. The browser localStorage does not have this field, but what happens when it does not take effect? there is no response. It doesn"t work to execute this directly in the browser: localStorage.setItem ("resultList", "11");

Jul.20,2021

I found out why, because I used global listening for local storage in another vue interface that is worth changing, so writing this later doesn't work. After that, the global monitoring local storage is removed and it will take effect.


1. Has this function been called?
where did 2.res come from?


res.list did not get the value, how do you define


localStorage stores strings. Do you see if res.list is a JSON string? if not, you should write

like this.
localStorage.setItem("resultList", JSON.stringify(res.list));

you need to change res.list into a string
I guess res.list is an array
https://www.cnblogs.com/LeoBo.

.
Menu