您好我收到以下错误。这段代码有什么问题?我试图添加css。还在学习drupal 8.我想知道这是什么问题。
这是我添加css的片段。我在css文件夹和库中的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文件夹和库中的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',
),
),
);
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'
答案 0 :(得分:1)
* .libraries.yml的内容似乎不正确。这应该是routing.yml的内容。
libraries.yml应该看起来不同: https://www.drupal.org/developing/api/8/assets
getInputField(id){
const inputId = `input_${id}`;
return(
<input ref={inputId}
id={inputId}
type="text"
value={this.state[`input${id}`]}
onChange={this.handleChange} />
);
}
render(){
const input36 = this.getInputField(36);
const input37 = this.getInputField(37);
return (
<div className="container">
<ul>
{this.renderListApplications()}
</ul>
<div>{JSON.stringify(this.data.currentApplication)}</div>
<form className="new-task" onSubmit={this.handleSubmit} >
{input36}
{input37}
...
</form>
</div>
);
}
答案 1 :(得分:0)
如果您的库在模块/扩展中定义,则每个库条目应具有以下所有必填字段:
docker inspect <container name>
您可以使用my-library-entry:
js: {}
css: {}
drupalSettings: {}
,js
和css
代替花括号:
drupalSettings
我不知道为什么my-library-entry:
js:
misc/ajax.js: {}
css:
theme:
css/cuddly-slider.css: {}
drupalSettings:
myDrupalSetting: null
条目是必需的,但似乎就是这种情况。