var self = this
IE11 から、読み取り専用変数であると言われましたが、宣言ポイントの後に何も割り当てていません。唯一の変数は、変化している高さです。とはいえ、使用時に変更することはできますvar
'厳密を使用';
var onDocumentLoad = require('fe-client-utils/src/dom/onDocumentLoad');
var onOrientationChange = require('fe-client-utils/src/dom/onOrientationChange');
var faPageHeight = function () {
};
var FA = {
init: function () {
this.faAddons = document.querySelector('.fa-addons');
this.faFooter = document.querySelector('.fa-footer');
this.extraWideChild = document.querySelector('.extraWide > div');
this.extraWide = document.querySelector('.extraWide');
this.faPages = document.querySelector('.fa-pages');
this.pageContent = document.getElementById('page-content');
this.faPageItems = document.querySelectorAll('.fa-page');
this.moveElements();
this.faPageHeight();
},
faPageHeight: function () {
var height = 0;
var self = this;
Object.keys(self.faPageItems).forEach(function (item, index) {
height += self.faPageItems[item].offsetHeight;
});
height += 150;
this.extraWideChild.style.height = height+'px';
},
moveElements: function () {
this.faAddons.style = '';
this.pageContent.appendChild(this.faAddons);
this.pageContent.appendChild(this.faFooter);
this.faFooter.style.display = 'block';
}
}
onDocumentLoad(function () {
FA.init();
});
onOrientationChange(function () {
FA.faPageHeight();
});
次のエラーが表示されますSCRIPT5045: Assignment to read-only properties is not allowed in strict mode
Microsoftによれば、読み取り専用プロパティを書き換えることはできないはずです。私は信じていません。では、なぜエラーが発生するのですか?
- 読み取り専用プロパティ
- 読み取り専用プロパティへの書き込み
- SCRIPT5045: strict モードでは、読み取り専用プロパティへの割り当ては許可されていません
- JavaScript
var testObj = Object.defineProperties({}, { prop1: { value: 10, writable: false // by default }, prop2: { get: function () { } } }); testObj.prop1 = 20; testObj.prop2 = 30;