簡體   English   中英

ES6 / ES2015舊瀏覽器中的Javascript不兼容(Edge 13,IE11等)

[英]ES6/ES2015 Javascript incompatibility in old browser (Edge 13, IE11, etc)

我有一個Javascript <script>代碼段(在這里嘗試: https : //apploitech.github.io/embed-snippets ),該代碼執行document.write(...) ,該代碼將許多html和javascript函數寫入DOM中。

Javascript函數之一可以做到這一點:

 document.addEventListener("DOMContentLoaded", function() { console.log("DOMContentLoaded calling renderJobs"); renderJobs(null, true, 1); }); 

它適用於大多數瀏覽器(Chrome,Safari,Edge 14/15),但是在以下瀏覽器上,IE / Edge開發人員工具控制台中Expected ')'顯示消息Expected ')' (如以下屏幕截圖所示):

  1. 13號邊緣以下
  2. IE11以下

有什么想法或最佳調試方法嗎? 我試着去炭1499類似的錯誤消息顯示,但什么也沒有相關的) 謝謝!

IE 11開發人員工具控制台

默認參數是ES6 / ES2015規范的一部分。

解:

function createPaginationButton(pagination_bar, page_num, isAppend) {
  if(isAppend === undefined) {
      isAppend = true;
   }
  ...
}

這是您的代碼段中的原始函數聲明,在較舊的瀏覽器中不受支持:

function createPaginationButton(pagination_bar, page_num, isAppend = true) {
    console.log("createPaginationButton(): page_num = " + page_num);
    var page_num_box = document.createElement("a");
    page_num_box.innerHTML = page_num;
    ...
    ...
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM