press-next
Version:
Vue3 组件库,支持 Composition API
31 lines (26 loc) • 612 B
text/typescript
// 不能额外依赖其他包,要干净。因为会注入到globalVar中,不能循环依赖
/**
* 刷新当前页面
*
* @param [isRedirect=false]
*/
export function refreshCurrentPage(isRedirect = false) {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
if (!currentPage) {
return;
}
if (currentPage && (currentPage as any).$page?.fullPath) {
const { fullPath } = (currentPage as any).$page;
const url = fullPath;
if (isRedirect) {
uni.redirectTo({
url,
});
return;
}
uni.reLaunch({
url,
});
}
}