2015-11-04 53 views
0

我使用webpack(1.12.2),react(0.14.2),react-router(1.0.0-rc4)和history(1.13.0)庫。未捕獲SecurityError:無法執行'歷史記錄'上的'replaceState':具有URL的歷史狀態對象

當我與建設項目的WebPack,谷歌瀏覽器的控制檯,我得到錯誤:

Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///Users/and/devel/Wond/index.html' cannot be created in a document with origin 'null'. 

createBrowserHistory.js線41

在我的源代碼(index.jsx)我用createBrowserHistory:

var createBrowserHistory = require('history/lib/createBrowserHistory'); 
let history = createBrowserHistory(); 

ReactDOM.render(<Router routes={routes} history={history} />, document.getElementById('content')); 
+1

https://stackoverflow.com/questions/32398578/history-replacestate-no-longer-working-in-chrome-for-local-file – Andreas

+0

然後我得到錯誤:'警告:位置「/用戶/和/ devel/Wond_dist/index.html「與任何路線不匹配」 – Matt

回答

3

您的文檔包含origin 'null',因爲您是從文件模式URI加載它的。

安裝Web服務器並從那裏加載您的HTML文檔。

相關問題