這是不可改變的記錄類定義永久記錄getIn在IE10失敗
import Immutable, {Record} from 'immutable';
const FEATURE_DEFAULTS = {
name: null,
};
export class Feature extends Record(FEATURE_DEFAULTS) {
}
一個實例初始化是這樣的:
const featureName = 'a value';
const b = new Feature({ name: featureName });
console.log(b.getIn(['name']));
在最現代的瀏覽器(Chrome瀏覽器,Safari瀏覽器等),它的工作原理。按預期打印出name
字段中的值。
然而,在IE10,b.getIn(['name'])
拋出此異常:Unable to get property 'hasOwnProperty' of undefined or null reference
我的項目的更多信息,
"immutable": "^3.8.1",
"react": "^15.1.0",
"react-chartist": "^0.10.1",
"react-dom": "^15.1.0",
"react-intl": "2.1.2",
"react-redux": "^4.4.5",
"react-router": "^2.4.1",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0",
"reselect": "^2.5.1",
我也使用babel
翻譯器ES6語法
"babel-core": "^6.9.1",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.9.0",
"babel-runtime": "^6.9.2",
我該如何解決這個問題?
編輯: 我覺得異常是從這裏拋出:
https://github.com/facebook/immutable-js/blob/38019326a8d006a45ef48d9c4644e23ea476d298/src/Record.js#L55