1
我與react-router
在Electorn遇到的問題是,我不能在電子應用點做這樣的事情,因爲window.location = '/'
到window.location
文件系統級主腳本的路徑。如何從組件以外的路線與電子`反應,router`?
我知道react-router
官方文件說做這樣
// history.js
import createBrowserHistory from 'history/lib/createBrowserHistory'
export default createBrowserHistory()
// index.js
import history from './history'
render(<Router history={history}/>, el)
// actions.js
import history from './history'
history.replaceState(null, '/some/path')
但調用history.replaceState()
在我的應用程序不執行任何操作。
最可疑和奇怪的部分是,雖然我用createBrowserHistory
爲我的路由器歷史window.location
打印哈希路徑。
有基於歷史路由任何電子具體問題?如果不是,爲什麼叫history.replaceState(null, '/')
不會使路由變化?