2015-11-04 30 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文档。

相关问题