electron-vite/electron-vite-react

构建Windows客户端后打开wouter显示空白,且没有任何报错,但在开发环境下运行正常,wouter是一个类似react-router的路由框架

liangtian123 opened this issue · 1 comments

Describe the bug

在开发环境中是正常的如下图:
image
但当我构建Windows客户端后,打开显示空白,如下图:
image

已经解决:要使用hash路由!参考https://github.com/molefrog/wouter/issues/202,根据这个链接配置就好了https://github.com/molefrog/wouter#customizing-the-location-hook
`
import {Route, Router} from 'wouter';
import { useLocationProperty, navigate } from "wouter/use-location";

const hashLocation = () => window.location.hash.replace(/^#/, "") || "/";

// @ts-ignore
const hashNavigate = (to) => navigate("#" + to);

const useHashLocation = () => {
const location = useLocationProperty(hashLocation);
return [location, hashNavigate];
};

export default () => {

return (

// @ts-ignore
<Router hook={useHashLocation}>
  <Menu/>
  <Route...../>
</Router>

);
};
`