Importing javascript from CDN in nbextension?

别等时光非礼了梦想. 提交于 2019-12-13 03:36:00

问题


I want to use https://crontab.guru/ in my nbextension, how can I include this from cdn in nbextension?


回答1:


According to https://requirejs.org/docs/api.html

Specify your CDN in the config -

requirejs.config({
    paths: {
        cron: '//unpkg.com/cronstrue@latest/dist/cronstrue.min'
    }
});

Do not append .js

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
    };
});


来源:https://stackoverflow.com/questions/52458388/importing-javascript-from-cdn-in-nbextension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!