reactjs - 单击链接后CSS受到干扰-react-router-dom
问题描述
我正在导出链接import { Link } from "react-router-dom"
,在我的 JSX 中我有
<Link to='/'>Back</Link>
当我单击时Link
,页面会呈现数据,但大多数css
都没有正确呈现。我使用了 material-ui 链接,但问题仍然存在。
import { Link } from "@material-ui/core";
<Link onClick={() => history.push('/')}> Back </Link>
应用程序.js
import React from "react";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import Dashboard from "./containers/landing_page";
import store from "./store";
import { Provider } from "react-redux";
import "./App.css";
function App() {
return (
<Provider store={store}>
<Router>
<Switch>
<Route path="/" component={Dashboard} />
</Switch>
</Router>
</Provider>
);
}
export default App;
PS:如果有帮助,我会在我的应用程序中使用@material-ui/core
&styled-components
解决方案
我不知道为什么会产生该错误,因为尽管我已修复它仍然没有任何意义
错误代码
{
product ?
<Grid>
<Link to='/'>Back</Link>
<Product product={product} />
</Grid> : null
}
使固定
<Grid>
<Link to='/'>Back</Link>
{
product ? <Product product={product} /> : null
}
</Grid>
推荐阅读
- reporting-services - 在 SSRS 折线图中隐藏空零数据点
- dictionary - 在 Go 的非指针类型函数中初始化映射
- javascript - 如何收集laravel控制器传递的数组并通过javascript检索它
- javascript - 如何使用 React 过滤表?
- c# - CS1061 - 不包含“Id”的定义,并且没有可访问的扩展方法“Id”接受类型的第一个参数
- python - Python matplotlib subplot datetime x ticks cutomization
- react-native - React Native 更新 0.63.0 破坏了真 iPhone 上的登录功能
- c# - 仅当 C# 中未发生另一个异常时如何捕获异常
- javascript - 在请求中运行请求(Node & Cheerio)
- mysql - MySQL INFORMATION_SCHEMA 错误