19 lines
470 B
TypeScript
19 lines
470 B
TypeScript
// 存储 TabBar 跳转参数
|
|
export const setGlobalData = (key: string, data: any) => {
|
|
if (!data) {
|
|
console.error("参数必须是一个对象");
|
|
return;
|
|
}
|
|
getApp().globalData[key] = data;
|
|
};
|
|
|
|
// 获取 TabBar 跳转参数(并自动清除)
|
|
export const getGlobalData = (key: string) => {
|
|
const params = getApp().globalData[key];
|
|
if (params) {
|
|
delete getApp().globalData[key]; // 获取后自动清理
|
|
return params;
|
|
}
|
|
return null;
|
|
};
|