有些時間我們希望能按需動態加載js文件,而不是直接在HTML中寫script標簽。
以下為示例代碼:
1 var js = document.createElement('script'); 2 js.async = true; 3 js.src = jsSrc; 4 js.onload = function() { 5 // 加載完成了 6 }
有些時間我們希望能按需動態加載js文件,而不是直接在HTML中寫script標簽。
以下為示例代碼:
1 var js = document.createElement('script'); 2 js.async = true; 3 js.src = jsSrc; 4 js.onload = function() { 5 // 加載完成了 6 }
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。