0👍
this is my code :
const lang = localStorage.lang;
if (!lang) {
lang = 'zh';
localStorage.lang = lang;
}
this is my error:
ERROR Failed to compile with 1 errors 10:49:28 AM
error in ./src/i18n/index.js
Module Error (from ./node_modules/eslint-loader/index.js):
error: Use object destructuring (prefer-destructuring) at src/i18n/index.js:6:7:
4 | Vue.use(VueI18n);
5 |
> 6 | const lang = localStorage.lang;
| ^
7 | if (!lang) {
8 | lang = 'zh';
9 | localStorage.lang = lang;
error: 'lang' is constant (no-const-assign) at src/i18n/index.js:8:3:
6 | const lang = localStorage.lang;
7 | if (!lang) {
> 8 | lang = 'zh';
9 | localStorage.lang = lang;
10 | }
11 | const req = require;
Source:stackexchange.com