sessionStorage 是不是有异步的问题? 怎么来处理
export async function get(params: { id: string, is_active?: 'False' | 'True', gr_id?: string, type?: 'single' }) {
const group_id = sessionStorage.getItem('gr_id')!; // 这里有时拿不到 gr_id, 怎么处理
params.gr_id = group_id, params.type = 'single'
return request.get<any, API.Response<FormRp>>(url, { params })
}
查看控制台 里面sessionStorage明明有 gr_id
export async function get(params: { id: string, is_active?: 'False' | 'True', gr_id?: string, type?: 'single' }) {
let group_id = (() => { return sessionStorage.getItem('gr_id')!})() // 这要写才有效,这是什么坑
params.gr_id = group_id, params.type = 'single'
return request.get<any, API.Response<FormRp>>(url, { params })
}