我得到这个错误属性'background'不存在类型'unknown'.ts(2339),当我试图使用这个代码
const location = useLocation();
const background = location.state && location.state.background;
我从react-router-dom中导入了所有需要的函数
import {
Redirect,
Route,
RouteComponentProps,
Switch,
useLocation,
withRouter,
} from "react-router-dom";
我使用类组件,如果它不重要。
如果你能给我一些建议我将非常感激。
import {Location} from "history";
const location = useLocation<{background?: Location<{} | null | undefined>}>();