如何使用Jquery导入Canvas.js?
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
<script src="https://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script>
有没有Jquery代码可以代替上面的html代码?
最佳答案
试试这段代码,
appendScriptToDocument("https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js", "jquery-3.2.1.min.js");
appendScriptToDocument("https://canvasjs.com/assets/script/jquery.canvasjs.min.js", "jquery.canvasjs.min.js");
function appendScriptToDocument(url, name){
var scriptLoader = document.createElement('script');
scriptLoader.src = url;
scriptLoader.scriptname = name;
scriptLoader.async = false;
//scriptLoader.addEventListener("load", scriptFileLoadSuccessCallback, false);// If you want to run any function after load success.
document.head.insertBefore(scriptLoader, document.head.firstChild);
}
在这里,我在 javascript 的帮助下向文档添加了一个脚本元素。
关于jquery - 如何使用 Jquery 导入 Canvas.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48002641/