We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
//main.tsx或者index.tsx中 const handleMicroData = () => { const navigate = useNavigate();//报错,原因是需要在组件中使用 const location = useLocation();//报错 if (window.eventCenterForAppSource) { const dt = window.eventCenterForAppSource.getData(); console.log("微应用【app-source】 getData:", dt); if (dt.path && typeof dt.path === "string") { console.log("子应用得到的路由-初始", dt.path, location.pathname); dt.path = dt.path.replace(/^#/, ""); if (dt.path && dt.path !== location.pathname) { debugger; navigate(dt.path as string); } } window.eventCenterForAppSource.addDataListener( (data: Record<string, unknown>) => { console.log("微应用【app-source】addDataListener:", data); if (data.path && typeof data.path === "string") { console.log("子应用得到的路由", data.path, location.pathname); data.path = data.path.replace(/^#/, ""); if (data.path && data.path !== location.pathname) { debugger; navigate(dt.path as string); } } } ); setTimeout(() => { window.eventCenterForAppSource.dispatch({ myname: "appSource" }); }, 3000); } };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
//main.tsx或者index.tsx中
const handleMicroData = () => {
const navigate = useNavigate();//报错,原因是需要在组件中使用
const location = useLocation();//报错
if (window.eventCenterForAppSource) {
const dt = window.eventCenterForAppSource.getData();
console.log("微应用【app-source】 getData:", dt);
if (dt.path && typeof dt.path === "string") {
console.log("子应用得到的路由-初始", dt.path, location.pathname);
dt.path = dt.path.replace(/^#/, "");
if (dt.path && dt.path !== location.pathname) {
debugger;
navigate(dt.path as string);
}
}
window.eventCenterForAppSource.addDataListener(
(data: Record<string, unknown>) => {
console.log("微应用【app-source】addDataListener:", data);
if (data.path && typeof data.path === "string") {
console.log("子应用得到的路由", data.path, location.pathname);
data.path = data.path.replace(/^#/, "");
if (data.path && data.path !== location.pathname) {
debugger;
navigate(dt.path as string);
}
}
}
);
setTimeout(() => {
window.eventCenterForAppSource.dispatch({ myname: "appSource" });
}, 3000);
}
};
The text was updated successfully, but these errors were encountered: