解决报错

This commit is contained in:
yuanteng 2024-10-27 18:51:02 +08:00
parent 44274cff5c
commit 248958fba8
3 changed files with 7 additions and 6 deletions

View File

@ -12,7 +12,7 @@ const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
//
app.use(ElementPlus, {size: 'small'})
//配置路由
app.use(router)

View File

@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import { myAxios } from '../api/myAxios'
import myAxios from '../api/myAxios'
export const userStore = defineStore( 'user' , {
//state是应用的核心数据通常用于管理用户信息、应用设置、数据列表等。
@ -17,14 +17,15 @@ export const userStore = defineStore( 'user' , {
//获取登录用户信息
async getLoginUser() {
//请求登录信息
const res = await myAxios.get('接口接口接口')
const res = await myAxios.get('/user/get')
// console.log(res.data)
if( res.data.code === 1 && res ?.data ) {
this.updateUser( res.data )
}
},
//更新用户信息
//更新state
updateUser(payLoad) {
updateUser(payLoad : any) {
this.loginUser = payLoad
}
}

View File

@ -41,7 +41,7 @@
import { ElMessage } from 'element-plus'
import {useRouter} from 'vue-router'
import myAxios from '@/api/myAxios';
import { userStore } from '@/store/userStore';
import { userStore } from '../store/userStore';
const user = ref({})
const username = ref('')
@ -54,7 +54,7 @@
userAccount: username.value,
userPassword: password.value
})
console.log(res.data.code)
// console.log(res.data.code)
if(res.data.code === 1 && res ?.data) {
//pinia
await store.getLoginUser()