Jquery Drupal 8 的 .once() 问题

Jquery .once() issue with Drupal 8

最近我用我的 Drupal 8 项目配置了 FullCalendar v3,它工作正常并且应用了所有功能。

问题与 JQUERY 3.3.1 有关,我使用 FullCalendar 作为配置导入。

当我忽略此 Jquery 加载时,问题会解决,但 FullCalendar 将不再工作。

我遇到了这些错误:

Uncaught TypeError: $(...).once is not a function

Uncaught TypeError: Cannot set property 'Bridge' of undefined

Uncaught TypeError: $(...).find(...).once is not a function

我搜索这些错误并尝试最佳匹配结果但尚未修复。 我改成其他jquery,激活主主题而不是子主题,但没有结果。

这是我的模块library.yml

amt_scripts:
  version: 1.x
  css:
    theme:
      assets/css/bootstrap.min.css: {}
      assets/css/fullcalendar.css: {}
      assets/css/amt_dayview.css: {}
  js:
    # assets/js/jquery-1.9.1.js: {}
    assets/js/jquery.min.js: {}
    assets/js/jquery-ui.min.js: {}
    assets/js/bootstrap.min.js: {}
    assets/js/moment.min.js: {}
    assets/js/fullcalendar.min.js: {}
    assets/js/scheduler.min.js: {}
    assets/js/popper.min.js: {}
    assets/js/amt_dayview.js: {}
  dependencies:

Batrik 主题形象:

你有没有添加像

这样的依赖
dependencies:
- core/jquery
- core/drupal.ajax
- core/drupal
- core/drupalSettings
- core/jquery.once

我使用这样的依赖项并从 Drupal 核心添加 jquery

amt_scripts:
  version: 1.x
  css:
    theme:
      assets/css/fullcalendar.css: {}
  js:
    assets/js/popper.min.js: {}
    assets/js/bootstrap.min.js: {}
    assets/js/moment.min.js: {}
    assets/js/fullcalendar.min.js: {}
    assets/js/scheduler.min.js: {}
    assets/js/amt_dayview.js: {}
  dependencies:
    - core/jquery
    - core/jquery-ui

但此方法适用于 hook_page_attachments,添加库:

ISSUE此方法会将库添加到所有页面,但我希望它在需要用当前路径检查它的特定页面上。

/**
 * Implemets hook_page_attachments().
 */
function amt_dayview_page_attachments(array &$attachments) {
  // Attach dayview Script just working fine with this hook.
  // But it is need to load just for dayview page.
  if (\Drupal::service('path.current')->getPath() == '/day-view') {
    // Unconditionally attach an asset to the page.
    $attachments['#attached']['library'][] = 'amt_dayview/amt_scripts';    
  }
}