Encountered a challenge today while working with Vue.
In a function, I cannot retrieve an element from a state. However, when I use console.log() to check the state, the element is present. Any suggestions on how to rectify this issue?
Here's the relevant code:
export const actions: ActionTree<IState, IState> = {
getUsers(context) {
// eslint-disable-next-line no-console
console.log('getUsers().context=', context);
// eslint-disable-next-line no-console
console.log('getUsers().context.state=', context.state);
// eslint-disable-next-line no-console
console.log('getUsers().context.state.baseURL=', context.state.baseURL);
// do something...
}
}
The log in the console:
The first log displays correctly. The value of baseURL is visible.
https://i.sstatic.net/yZRGI.png
The second log also shows the value of baseURL. https://i.sstatic.net/sIDzW.png
The third log presents the problem. The value of baseURL cannot be retrieved!!! https://i.sstatic.net/KpHBK.png
Information from package.json file:
{
"name": "ui",
"version": "2.0.0-rc",
"private": true,
"author": "Leo Wu <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c1b6b4a5aeafa6b8a8af81a6aca0a8adefa2aeac">[email protected]</a>>",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
... (remaining content omitted for brevity)
If more information is required, please feel free to ask.
Appreciate any assistance provided.