Skip to content

Commit bcf5795

Browse files
janostudiojiangjiawei.feddanpeen
authored
feat: 处理useRoute()为undefined的场景 (#3589)
Co-authored-by: jiangjiawei.fed <jiangjiawei.fed@bytedance.com> Co-authored-by: CocooDanielle <dapeen.feng@gmail.com>
1 parent f302eeb commit bcf5795

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/bridge/vue3-bridge/src/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function createRemoteComponent(info: {
1919
const route = useRoute();
2020

2121
let basename = '/';
22-
const matchPath = route.matched[0]?.path;
22+
const matchPath = route?.matched?.[0]?.path;
2323
if (matchPath) {
2424
if (matchPath.endsWith('/:pathMatch(.*)*')) {
2525
basename = matchPath.replace('/:pathMatch(.*)*', '');

packages/bridge/vue3-bridge/src/remoteApp.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default defineComponent({
5656
};
5757

5858
const watchStopHandle = watch(
59-
() => route.path,
59+
() => route?.path,
6060
(newPath) => {
6161
if (newPath !== route.path) {
6262
renderComponent();

0 commit comments

Comments
 (0)