如何在CDN文件中包含CDN(* .js)? [英] How to include CDN in javascript file (*.js)?
问题描述
我知道如何在HTML文件中包含CDN.
I know how to include CDN in HTML file.
<!DOCTYPE html>
<html>
<head>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
</body>
</html>
但是我想做的是:
我想在我的JavaScript文件中包含CDN(例如jquery).
But what I am trying to do is:
I want to include CDN like jquery in my javascript file.
可能我想做的是不可能的.
实际上,我想从我的JavaScript文件中调用 BootstrapDialog.Confirm .
因此,我想在js文件中包含BootstrapDialog所需的CDN.
然后,我可以调用 BootstrapDialog.Confirm .
May be what I am trying to do is impossible.
Actually, I want to call BootstrapDialog.Confirm from my javascript file.
So, I want to include required CDN for BootstrapDialog in js file.
Then I can call BootstrapDialog.Confirm.
如果我的问题不合理,请原谅我,因为我是初学者.
If my question is not reasonable, forgive me as I am a beginner.
推荐答案
您可以使用Javascript完成此操作:
You can do it in Javascript:
var jQueryScript = document.createElement('script');
jQueryScript.setAttribute('src','https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js');
document.head.appendChild(jQueryScript);
这篇关于如何在CDN文件中包含CDN(* .js)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!