drupal7:
加载 css文件
drupal_add_css(drupal_get_path('module', 'example') . '/example.css');
加载js文件
drupal_add_js(drupal_get_path('module', 'example') . '/example.js');
Loading a library in Drupal 7
drupal_add_library('example', 'drag-and-drop');
drupal8:
加载 css文件
$example = array(
'#attached' => array(
'css' => array(
drupal_get_path('module', 'example') . '/css/example.css' => array(),
),
),
);
加载js文件:
$example = array(
'#attached' => array(
'js' => array(
drupal_get_path('module', 'example') . '/js/example.js' => array(),
),
),
);
Loading a library in Drupal 8
$example = array(
'#attached' => array(
'library' => array(
'example/drag-and-drop',
),
),
);