我有一个数组 arr 从控制器发送到包含一些 JavaScript 脚本的 twig 模板,我想使用 for 循环来访问数组的行,如下所示:
for (var i = 0; i < 3; i++) {
alert('{{ arr[i] }}');
}
Run Code Online (Sandbox Code Playgroud)
但变量 i 未知,我收到此错误:
变量“i”不存在。
有什么建议么?
我正在设法解决这个问题:我不知道为什么调试调试不起作用:
Drupal版本8.2.6
Folder structure
Folder permissions
Settings.php
$settings['hash_salt'] = 'DEVELOPMENT_SALT';
$settings['update_free_access'] = FALSE;
$settings['file_public_base_url'] = 'http://localhost/files';
$settings['file_public_path'] = 'sites/default/files';
$settings['file_private_path'] = 'sites/default/private';
$settings['file_scan_ignore_directories'] = [
'node_modules',
'bower_components',
];
if (file_exists(__DIR__ . '/../development/settings.development.php')) {
include __DIR__ . '/../development/settings.development.php';
}
Run Code Online (Sandbox Code Playgroud)
/../development/settings.development.php
assert_options(ASSERT_ACTIVE, TRUE);
\Drupal\Component\Assertion\Handle::register();
/**
* Enable local development services.
*/
$settings['container_yamls'][] = __DIR__ . '/development.services.yml';
$databases['default']['default'] = array(
'database' => 'dbname',
'username' => 'dbusername',
'password' => 'pw',
'prefix' => '',
'host' => '127.0.0.1',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', …Run Code Online (Sandbox Code Playgroud) 我写了 HTML 表格,其中每一行都有复选框。所以现在我想在我的标题中添加复选框,它将检查表中的所有复选框。我已经做到了,但它不起作用。任何的想法?
<table class="table table-hover table-inbox">
<thead>
<tr>
<th>
<input type="checkbox" class="i-checks" id="allmsgs">
</th>
<th>Sender</th>
<th>Message</th>
<th>Last Message</th>
</tr>
</thead>
<tbody>
<tr class="">
<td class="">
<input type="checkbox" name="1" class="i-checks msg">
</td>
<td><a href="#">Jeremy Massey</a></td>
<td><a href="#">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a></td>
<td class="mail-date"><a href="#">12/12/2019 15:35</a></td>
</tr>
<tr class="unread active">
<td class="">
<input type="checkbox" name="2" class="i-checks msg">
</td>
<td><a href="#">Marshall Horne</a></td>
<td><a href="#">Praesent nec nisl sed neque ornare maximus at ac enim.</a></td>
<td class="mail-date">12/12/2019 15:35</td>
</tr>
<tr>
<td …Run Code Online (Sandbox Code Playgroud)
transparent-- 指定颜色应该是透明的。这是默认值
inherit——从其父元素继承此属性。
但实际上,我看不出它们有什么区别。在以下示例中,两个子元素都将具有coral背景颜色。
<div style="background-color: coral">
<div style="background-color: transparent">
transparent
</div>
<div style="background-color: inherit">
inherit
</div>
</div>Run Code Online (Sandbox Code Playgroud)
在什么条件下我会得到不同的结果?