The asyncData parameter in nuxt in nuxt, and the problem that the value of context store is empty after the page is refreshed.

functional requirements:
there is a search box on the home page and a search box on the list page. Enter the search content on the home page and jump to the search page to perform the search

.

nuxt implementation:
save the searchKeyWords field into vuex, on the home page, then go to the search page to get the searchKeyWords field, and perform a search

question:
after jumping from the home page to the search page, after the page is refreshed, the data in the searchKeyWords,store obtained through the context store turns out to be empty

.
async asyncData({ store, params }) {
            let searchParams = {
                keyword: store.state.searchKeyWords,  //searchKeyWords
                pageNo: 1,
                pageSize: 10
            }
            let { result } = await API.searchMethod(searchParams);
            return {
                searchData:resul
            }
        }

but there is data in vuex

clipboard.png

May.26,2021

when you refresh, the value of store is actually empty. You can console.log it. Sometimes plug-ins cannot be updated in real time. Take a look at the route authentication of nuxt official website. the user information to be saved by https://zh.nuxtjs.org/example. is stored in session. Then it is written to the front-end layer through the nuxtServerInit cycle. Of course, there are some problems here on the official website. The session module used in the middle layer here can only be used in the development mode, and the generation mode cannot be run. How do you solve it by using redis


?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1beed51-30974.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1beed51-30974.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?