所以我面临的问题是这个。当我加载页面时,没有呈现 Header 组件的样式,但是当我删除加载逻辑时它们是。问题可能出在 Header 组件 BCS 中,它位于除 Login 之外的每个 Route 中。我需要在除登录之外的每条路径上呈现它。错误可能在哪里?
const Cart = loadable(
() =>
new Promise((resolve, reject) =>
setTimeout(() => resolve(import("./components/Cart/Cart")), 100)
),
{
fallback: <div className="login__loader">
<img src='./audie/Glowing ring.gif' alt= ''></img>
</div>
}
);
const Book = loadable(
() =>
new Promise((resolve, reject) =>
setTimeout(() => resolve(import('./components/Home/Book')), 100)
),
{
fallback: <div>Loading...</div>
}
);
const App=()=> {
return (
<React.Fragment>
<Switch>
<Route exact path='/'>
<Header />
<Home />
</Route>
<Route path="/cart">
<Header />
<Cart />
</Route>
<Route path="/stripecontainer">
<Header />
<StripeContainer />
</Route>
<Route path='/book/:bookId'>
<Header />
<Book />
</Route>
<Route path='books'>
<Books/>
</Route>
<Route path='/forgotpassword'>
<ForgotPassword />
</Route>
<Route path='/passwordreset/:resetToken'>
<ResetPassword />
</Route>
<Route exact path='/register'>
<Register />
</Route>
<Route path='/login'>
<Login />
</Route>
</Switch>
</React.Fragment>
);
}
export default App