问题描述
我知道如何在 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 文件中包含像 jquery 这样的 CDN.
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);
这篇关于如何在javascript中包含CDN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!