我试图在我的主反应(index.js)中添加下面提到的javascript
代码
但是在(函数hookHistoryBoomerang())的位置出现意外的令牌错误。
import React from 'react'
import {
render
} from 'react-dom'
import {
createStore
} from 'redux'
import {
Provider
} from 'react-redux'
import App from './components/App'
import reducer from './reducers'
(function () {
var history;
var hadRouteChange = false;
var hookOptions = {};
if (BOOMR.plugins.History || typeof BOOMR.plugins.SPA === "undefined") {
return;
}
BOOMR.plugins.SPA.register("History");
BOOMR.plugins.History = {
function hookHistoryBoomerang() {
if (window.BOOMR && BOOMR.version) {
if (BOOMR.plugins && BOOMR.plugins.History) {
BOOMR.plugins.History.hook(history, hadRouteChange);
}
return true;
}
}
if (!hookHistoryBoomerang()) {
if (document.addEventListener) {
document.addEventListener("onBoomerangLoaded", hookHistoryBoomerang);
} else if (document.attachEvent) {
document.attachEvent("onpropertychange", function (e) {
e = e || window.event;
if (e && e.propertyName === "onBoomerangLoaded") {
hookHistoryBoomerang();
}
});
}
}
function onEnter() {
hadRouteChange = true;
}
};
}(BOOMR.window));
const store = createStore(reducer)
render(
<Provider store={ store }>
<Router history={ history } onEnter={ onEnter } />
<App />
</Provider>,
document.getElementById('root')
)
1.我的代码出了什么问题?
2.如果我错过任何事情,请帮我解决这个问题。