Drupal jQuery 依赖项抛出错误“网站遇到意外错误。请稍后再试。”

问题描述 投票:0回答:1

我对 Drupal (8) 及其模板系统还很陌生。我设置了一个 themename.libraries.yml 和一个 themename.info.yml ,如下所示:

xxx.info.yml:

    name: xxx
    description: theme for xxx
    type: theme
    core: 8.x
    package: Custom
    basetheme: classy
    libraries:
      - xxx/stylesheets
      - xxx/javascript
    regions:  
      content: Content
      pagetitle: Pagetitle
      searchblock: Searchblock

xxx.libraries.yml

    stylesheets:
      css:
        theme:
          css/style.css: {}
          https://fonts.googleapis.com/css?family=Open+Sans: {}
          https://fonts.googleapis.com/css?family=Montserrat: {}
    javascript:
      js:
          js/site.js: {}
          js/sticky.js: {}

这工作得很好,就像我想要的那样。但是当我注销时,core-jQuery 没有加载。所以我发现,我必须补充:

 dependencies:
          - core/jquery: {}

使 Drupal 为匿名用户集成 jQuery。但每次我添加行依赖项: - core/jquery: {} 并清除缓存时,整个站点都会中断并返回白屏:

“网站遇到意外错误,请稍后重试。”

jquery drupal theming
1个回答
2
投票

- core/jquery: {}
应该是
- core/jquery

这是一个例子:

my_awsome_module:
  version: 1.x
  js:
    js/my_awesome_module.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once
© www.soinside.com 2019 - 2024. All rights reserved.