我正在嘗試使用React Shepherd為我的應(yīng)用程序創(chuàng)建演練。我似乎找不到任何解釋如何在游覽中切換路線的內(nèi)容。window.location.replace = "/someurl" 刷新頁(yè)面并完全終止游覽。我正在努力實(shí)現(xiàn)這一目標(biāo)歷史.jsimport { createBrowserHistory } from "history";const history = createBrowserHistory();export default history;步驟.jsimport hist from "./History";const Steps = [ { //... when: { hide: () => { hist.push("/someurl"); }, }, },//...]export default Steps;應(yīng)用程序.jsimport React from "react";import { Router } from "react-router";import { Route } from "react-router-dom";//...import Steps from "./Steps";import hist from "./History";import "shepherd.js/dist/css/shepherd.css";const tourOptions = { defaultStepOptions: { cancelIcon: { enabled: true, }, classes: "shepherd-theme-custom", }, useModalOverlay: true,};const App = () => { return ( <Router history={hist}> <Route exact path="/signin" component={SignIn} /> <ShepherdTour steps={Steps} tourOptions={tourOptions}> <PrivateRoute exact path="/*" component={Main} /> </ShepherdTour> </Router> );};export default App;調(diào)用steps的hide函數(shù)時(shí),url路徑切換了,頁(yè)面沒有渲染。我想知道我是否錯(cuò)誤地使用了 react-router 或者是否有不同的方法來(lái)解決這個(gè)問題?
如何在 React Shepherd 中訪問瀏覽器歷史記錄
慕神8447489
2023-03-24 17:15:37