|
|
@@ -1,5 +1,5 @@
|
|
|
import { PropsWithChildren } from 'react';
|
|
|
-import { useLaunch } from '@tarojs/taro';
|
|
|
+import Taro, { useLaunch, usePageNotFound } from '@tarojs/taro';
|
|
|
|
|
|
import '@nutui/nutui-react-taro/dist/style.css';
|
|
|
import '@nutui/nutui-react-taro/dist/styles/themes/jmapp.css';
|
|
|
@@ -19,6 +19,12 @@ function App({ children }: PropsWithChildren<any>) {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // 页面不存在兜底:线上环境严格校验页面路径时,可避免白屏/错误页
|
|
|
+ usePageNotFound((res) => {
|
|
|
+ console.error('[App] onPageNotFound — path:', res.path, 'isEntryPage:', res.isEntryPage);
|
|
|
+ Taro.reLaunch({ url: '/pages/index/index' });
|
|
|
+ });
|
|
|
+
|
|
|
// children 是将要会渲染的页面
|
|
|
return children;
|
|
|
}
|