gpt4 book ai didi

drupal - 不完整的库定义 drupal 8

转载 作者:行者123 更新时间:2023-12-02 17:30:07 25 4
gpt4 key购买 nike

您好,我收到以下错误。这段代码有什么问题?我正在尝试添加 CSS。还在学习drupal 8。我想知道是什么问题。

这是我添加 CSS 的片段。我在css文件夹和libraries中的css与路由yml文件同级。

The website encountered an unexpected error. Please try again later.

Drupal\Core\Asset\Exception\IncompleteLibraryDefinitionException: Incomplete library definition for definition 'test-module' in extension 'test_module' in Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension() (line 96 of core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).

Drupal\Core\Asset\LibraryDiscoveryCollector->getLibraryDefinitions('test_module')
Drupal\Core\Asset\LibraryDiscoveryCollector->resolveCacheMiss('test_module')
Drupal\Core\Cache\CacheCollector->get('test_module')
Drupal\Core\Asset\LibraryDiscovery->getLibrariesByExtension('test_module')
Drupal\Core\Asset\LibraryDiscovery->getLibraryByName('test_module', 'test-module')
Drupal\Core\Asset\LibraryDependencyResolver->doGetDependencies(Array)
Drupal\Core\Asset\LibraryDependencyResolver->getLibrariesWithDependencies(Array)
Drupal\Core\Asset\AssetResolver->getLibrariesToLoad(Object)
Drupal\Core\Asset\AssetResolver->getCssAssets(Object, 1)
Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAssetLibraries(Object, Array)
Drupal\Core\Render\HtmlResponseAttachmentsProcessor->processAttachments(Object)
Drupal\Core\EventSubscriber\HtmlResponseSubscriber->onRespond(Object, 'kernel.response', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.response', Object)
Symfony\Component\HttpKernel\HttpKernel->filterResponse(Object, Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)

这是我添加 CSS 的片段。我在css文件夹和libraries中的css与路由yml文件同级。

        $element = array(
'#markup' => '<p><b>Saying Hello World in Drupal 8 is cool!</b></p>' . $content,
'#attached' => array(
'library' => array(
'test_module/test-module',
),
),
);

测试模块.libraries.yml

test_module_settings:
path: '/hello/test'
defaults:
_controller: '\Drupal\test_module\Controller\TestModuleController::myCallbackMethod'
_title: 'Hello World'
requirements:
_permission: 'view hello world'

最佳答案

如果您的库是在您的模块/扩展中定义的,它应该为每个库条目包含以下所有必填字段:

my-library-entry:
js: {}
css: {}
drupalSettings: {}

您可以用您的 jscssdrupalSettings 替换大括号,如下所示:

my-library-entry:
js:
misc/ajax.js: {}
css:
theme:
css/cuddly-slider.css: {}
drupalSettings:
myDrupalSetting: null

我不知道为什么需要 drupalSettings 条目,但似乎是这样。

关于drupal - 不完整的库定义 drupal 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34435445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com