export const useStore = defineStore("main", () => {
const customerId = ref(0)
const customerInfo = ref({})
if (sessionStorage.getItem('store')) {
const storeDate = (JSON.parse(sessionStorage.getItem('store')))
customerId.value=storeDate.customerId
customerInfo.value= {
...storeDate.customerInfo
}
}
window.addEventListener("beforeunload", () => {
sessionStorage.setItem("store", JSON.stringify({
customerId: customerId.value,
customerInfo: {
...customerInfo.value
}
}));
});
return {
customerInfo,
customerId,
}
})
vue3属性pinia(store)数据丢失-记录一下
猜你喜欢
转载自blog.csdn.net/qq_48109675/article/details/130445428
今日推荐
周排行