I believe I did everything right, this is killing me!!!
I’m learning Vue2 rn, this is a part of a login system practice project I’m working on.
Basically after entering username and password, when hitting the button, this warning jumps out.

Here is the methods segment of src/views/Login/Login.vue
methods: {
login() {
this.$refs.loginForm.validate(async (valid) => {
if (!valid) return;
const {
data: { userId: res },
} = await this.$http.get(
'https://jsonplaceholder.typicode.com/posts/1'
);
console.log(res);
if (res === 1) {
this.$message.success('Success!');
this.$store.commit('user/updateToken', res);
this.$router.push('/main');
}
});
},
},
here is the src/store/index.js
import Vue from 'vue';
import Vuex from 'vuex';
import user from './user';
Vue.use(Vuex);
export default new Vuex.Store({
state: {},
getters: {},
mutations: {},
actions: {},
modules: {
user,
},
});
Here is the src/store/user.js
export default {
namespaced: true,
state: {
token: '',
},
mutations: {
updateToken(state, res) {
state.token = res;
localStorage.setItem('token', res);
},
},
actions: {},
getters: {},
};
Here is src/router/index.js
import Vue from 'vue';
import VueRouter from 'vue-router';
import Reg from '../views/Reg/Reg.vue';
import Login from '../views/Login/Login.vue';
import Main from '../views/Main/Main.vue';
Vue.use(VueRouter);
const routes = [
{
path: '/',
redirect: '/login',
},
{
path: '/reg',
component: Reg,
},
{
path: '/login',
component: Login,
},
{
path: '/main',
component: Main,
},
];
const router = new VueRouter({
routes,
});
export default router;
Here is the src/main.js
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './assets/global.less';
import axios from 'axios';
//安裝elementUi
Vue.use(ElementUI);
//將axios掛在到原型prototype上,全局使用
Vue.prototype.$http = axios;
Vue.config.productionTip = false;
new Vue({
router,
store,
render: (h) => h(App),
}).$mount('#app');
I tried asking chatGPT, I sent all my codes to it, and it didn’t seem to be capable of finding the problem. So I have to turn to you guys, who’s obviously more intelligent and experienced!