How to dynamically introduce JS files

php中世界最好的语言
Release: 2018-05-23 14:43:03
Original
1947 people have browsed it

This time I will show you how to dynamically introduce JS files. What are theprecautions for dynamically introducing JS files? Here are practical cases, let’s take a look.

index.html

       
   
Copy after login

test.js

alert("hello! I am test.js"); var str="1";
Copy after login

dynamic.js

//第一种方式:直接document.write 但这样会把当前的页面全覆写掉 //document.write("