【问题标题】:How do i add the css and js in the controller file of Drupal8?如何在 Drupal 8 的控制器文件中添加 css 和 js?
【发布时间】:2017-07-13 07:16:37
【问题描述】:

在我的控制器页面中,我正在调用我的 css。因为我忘了调用信息文件,所以它不起作用

$build['location_table'] = array(
  '#theme' => 'table',
  '#header' => $headers,
  '#rows' => $table_rows,
  '#empty' => t('No data is available'),
  '#attributes' => array(
    'id' => 'docgenr-list-table',
    'width' => '100%',
    'library' =>  array(
            'addmetafeeds/addmetafeeds_creation_css',

        ),
  ),
);

我的库文件:

addmetafeeds_creation_css:
    version: 1.x  
        css: 
           theme:   
               css/addmetafeeds_creation.list.css: {}

【问题讨论】:

    标签: drupal drupal-modules drupal-8


    【解决方案1】:

    我不确定你的问题,但是......

    通常是:

    '#attached' => array(
        'library' => array(
            'addmetafeeds/addmetafeeds_creation_css',
        ),
    ),
    

    假设您需要 CSS 和 JS 文件,例如库文件中的示例...

    addmetafeeds_creation_css:
        css:
            theme:
                css/addmetafeeds_creation.list.css: {}
        js:
            js/js.js: {}
    

    请看这里:https://www.drupal.org/docs/8/theming-drupal-8/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-theme

    【讨论】:

    • 谢谢,这是我需要的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多