-2
您好我有這段代碼在Chrome中工作正常,但不是在IE 11中。 我想這是ES6語法,但不是很確定。ES6的JS代碼不工作在IE 11的地圖()
var buf2Hex = function(buffer) {
//return Array.prototype.map.call(new Uint8Array(5).join('00').concat(buffer.data.toString(16)).slice(-2)).join('');
return Array.prototype.map.call(new Uint8Array(buffer.data), x=>('00'+x.toString(16)).slice(-2)).join('');
}
評論行是我嘗試過但沒有工作。
如何使它適用於IE?
它怎麼樣?你的控制檯是否有錯誤? –
我不認爲問題是[map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map?v=example),它有自IE9以來一直支持,是的,[箭頭函數](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)('=>()')是ES6,並且是不支持IE瀏覽器(但我認爲你已經明白了) –
關於錯誤,我在IE中得到了這個:錯誤:[ng:areq] http://errors.angularjs.org/1.2.16/ng/areq? p0 = MyCtrl&p1 = not%20a%20function%2C%20got%20undefined如果我拿出這個函數,頁面加載沒有錯誤。 – user3552178