从CDN中的nbextension导入JavaScript? [英] Importing javascript from CDN in nbextension?
本文介绍了从CDN中的nbextension导入JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的nbextension中使用 https://crontab.guru/,我如何才能将其包含在CDN处于nbextension吗?
I want to use https://crontab.guru/ in my nbextension, how can I include this from cdn in nbextension?
推荐答案
根据 https://requirejs .org/docs/api.html
在配置中指定您的CDN-
Specify your CDN in the config -
requirejs.config({
paths: {
cron: '//unpkg.com/cronstrue@latest/dist/cronstrue.min'
}
});
请勿附加.js
在定义load_ipython_extension的AMD模块中,将cron定义为依赖项-
In your AMD module which defines load_ipython_extension, define cron as dependency-
define(['cron'], function(cron){
function load_ipython_extension(){
console.log(cron.toSrting("* * * * *"));
}
return {
load_ipython_extension: load_ipython_extension
};
});
这篇关于从CDN中的nbextension导入JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文