【发布时间】:2019-07-31 10:35:58
【问题描述】:
如果我的问题很愚蠢,我很抱歉。我的jQuery 代码仅在我以管理员身份登录时才有效。当我没有登录时,它不工作,并且我在控制台中出现错误:Drupal is not defined。
我的main.js 文件是这样的:
(function ($, Drupal, window, document, undefined) {
$(document).ready(function(){
code goes here
});
})(jQuery, Drupal, this, this.document);
mytheme.libraries.yml(我创建了一个自定义主题)看起来是这样的:
global-styling:
js:
js/main.js: {}
css:
component:
css/style.css: {}
dependencies:
- mytheme/slick
slick:
css:
theme:
/libraries/slick/slick/slick.css: {}
js:
/libraries/slick/slick/slick.min.js: {}
dependencies:
- core/jquery
请帮忙。
编辑
global-styling:
js:
js/main.js: {}
css:
component:
css/style.css: {}
dependencies:
- mytheme/slick
- core/drupal
我在依赖项中添加了 core/drupal,现在没有错误,但是当我没有登录时,jQuery 仍然无法工作。
【问题讨论】:
-
尝试将
core/drupal添加到您的依赖项中 -
我现在编辑了我的帖子。添加核心/drupal 并没有完全帮助:(@BrettGregson
标签: javascript jquery drupal drupal-8