【发布时间】:2021-09-21 21:37:31
【问题描述】:
我的自定义主题上有两个 JavaScript 文件。一个文件具有需要在另一个文件上使用的功能。我下面的东西不起作用。这是我得到的错误。
Uncaught ReferenceError: test is not defined.
jQuery 将用于这两个文件。
file1.js
/**
* @file
* UI behaviors
*/
(function ($, Drupal) {
'use strict';
$(document).ready(function () {
function test(){
console.log('hello'):
}
});
})(jQuery, Drupal);
file2.js
/**
* @file
* UI behaviors
*/
(function ($, Drupal) {
'use strict';
$(document).ready(function () {
test();
});
})(jQuery, Drupal);
customtheme.libraries.yml
scripts:
js:
js/file1.js: {}
js/file2.js: {}
customtheme.info.yml
libraries:
- 'customtheme/scripts'
【问题讨论】:
标签: javascript drupal