How to load Tempus Dominus Bootstrap 4 with requirejs (in Moodle) ? ( Error: No define call for datetimepicker)

How to load Tempus Dominus Bootstrap 4 with requirejs (in Moodle) ? ( Error: No define call for datetimepicker)

你好,我在 Moodle 3.5 中使用 requirejs 来包含 js 文件,但我对 Tempus Dominus 有问题Bootstrap 4.

这是我的config.js

define([], function () {
window.requirejs.config({

    paths: {
        "moment": 'https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min',                   
        "datetimepicker":'https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.0-alpha14/js/tempusdominus-bootstrap-4.min',
    },
    shim: {
        'datetimepicker': {deps: ['jquery','moment'], exports: 'datetimepicker'},
    }
});
});

datetimepicker.js

define(['myfolder/config', 'datetimepicker'], function(unused,datetimepicker) {
    return datetimepicker;
}
);

myapp.js

define([
'jquery',
'myfolder/moment',
 'myfolder/datetimepicker',
],
function ($,moment) {
    function initManage() {

并抛出错误:"No define call for datetimepicker";

怎么了?

垫片必须是:

datetimepicker: { exports: "$.fn.datetimepicker"   }

文件如下: config.js

define([], function () {
  window.requirejs.config({

    paths: {
        "moment": M.cfg.wwwroot + '/admin/tool/myplugin/js/moment.min',
        "moment-fr": M.cfg.wwwroot + '/admin/tool/myplugin/js/moment-fr',
        "bootstrap": M.cfg.wwwroot + '/admin/tool/myplugin/js/bootstrap.bundle.min',
        "datetimepicker":M.cfg.wwwroot + '/admin/tool/myplugin/js/tempusdominus-bootstrap-4',
    },
    shim: {
        bootstrap: { deps: ["jquery"], exports: 'bootstrap'},
       datetimepicker: { exports: "$.fn.datetimepicker"   }
    }
  });
});

datetimepicker.js

define(['tool_myplugin/config',  'datetimepicker'], function(unused,datetimepicker) {
    return datetimepicker;
});

和app.js

define([
'jquery',
'tool_myplugin/moment',
'tool_myplugin/bootstrap',
'tool_myplugin/datetimepicker'
],
function ($,moment) {

    function initManage() {

        $(document).ready(function () {  
            $('#datetimepicker1').datetimepicker({
                format: 'HH:mm',
                use24hours: true,
                defaultDate: moment({hour: 9,minute:0})
        });  
 ...