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

时间:2018-05-04 20:04:11

标签: jquery drupal core theming

我对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:{}并清除缓存,整个站点中断并返回一个白屏:

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

1 个答案:

答案 0 :(得分:2)

- core/jquery: {}应该是- core/jquery
这是一个例子:

my_awsome_module:
  version: 1.x
  js:
    js/my_awesome_module.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once