---
title: 代码抽屉
slug: docs/cn/78WZFKAq47oVy6mmoOdT4
description: 本文档展示了三个实用的代码抽屉示例，可在三栏布局中以美观的方式显示代码示例。包括用 JavaScript 和 Python 编写的代码，这些示例提供了全面的演示 t
createdAt: 2022-07-04T12:42:31.000Z
---

代码抽屉是在三栏布局中展示代码示例的绝佳方式。

这里有一个：‘‘‘

::::CodeDrawer{title="A code drawer" isResponseExpanded="true" autoGeneratedAnchorSlug="a-code-drawer" legacyHash="S9e7LDxVHJ50RmqAIvHnf"}
:::CodeblockTabsExamples
```javascript
let x, y, z;  // Statement 1
x = 5;        // Statement 2
y = 6;        // Statement 3
z = x + y;    // Statement 4

document.getElementById("demo").innerHTML =
"The value of z is " + z + ".";  
```

```python
# Program to find the sum of all numbers stored in a list

# List of numbers
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]

# variable to store the sum
sum = 0

# iterate over the list
for val in numbers:
    sum = sum+val

print("The sum is", sum)
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::

这里还有一个。

::::CodeDrawer{title="Another code drawer" isResponseExpanded="true" autoGeneratedAnchorSlug="another-code-drawer" legacyHash="UwiH3lFnllMs_SW-1EITy"}
:::CodeblockTabsExamples
```javascript
let x, y, z;  // Statement 1
x = 5;        // Statement 2
y = 6;        // Statement 3
z = x + y;    // Statement 4

document.getElementById("demo").innerHTML =
"The value of z is " + z + ".";  
```

```python
# Program to find the sum of all numbers stored in a list

# List of numbers
numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]

# variable to store the sum
sum = 0

# iterate over the list
for val in numbers:
    sum = sum+val

print("The sum is", sum)
```
:::

:::CodeblockTabsResponses
```javascript
```
:::
::::

以及编辑时的截图：

![](https://api.archbee.com/api/optimize/bNBm7nPJgXjbjLyfbHNh2/kbx_YaJkagc8DztKeSYkR_code-drawer-light.png "Code drawers")

## Markdown

使用以下 Markdown 生成 code drawer 区块：

````markdown
### Test codedrawer

::::codedrawer{title="a code drawer"}
:::codeblocktabs-examples
```php
// Some wordpress plugi
 // Add our plugin's option page to the WP admin menu.
  public function add_plugin_options_page() {
    add_options_page(
      'Example Plugin Settings',
      'Example Plugin Settings',
      'manage_options',
      'ex',
      [$this, 'render_admin_page']
    );
  }
```
```go
// Next should be used only inside middleware.
// It executes the pending handlers in the chain inside the calling handler.
// See example in GitHub.
func (c *Context) Next() {
    c.index++
    for c.index < int8(len(c.handlers)) {
        c.handlers[c.index](c)
        c.index++
    }
}
```
```javascript
// demo js
```
:::
:::codeblocktabs-responses
```json
// 404 -  not found
{
  requireFingerprintScope: true,
  maxMachines: 1,
  concurrent: false,
  floating: false,
  protected: true,
  strict: true
}
```
:::
::::
````

***

::::LinkArray
:::LinkArrayItem{headerType="IMAGE" headerImage="https://api.archbee.com/api/optimize/K_JWZranXy1tD6qvlG2v6-C1IcmVcG0rx4ZLHX6X7V7-20250911-192557.png"}
:FontAwesome[]{icon="fa-solid fa-cubes"} &#x20;**&#x20;查找其他区块**

探索用于创建精美且实用文档页面的新方法和区块。

[查看所有区块](docId\:B4IohMBgLgJ5t-HvaLMTF)&#x20;
:::

:::LinkArrayItem{headerType="IMAGE" headerImage="https://api.archbee.com/api/optimize/K_JWZranXy1tD6qvlG2v6-YRyGGWKsNS1ZZJa5XJy0z-20250911-192608.png"}
:FontAwesome[]{icon="fa-solid fa-headset"}**&#x20; 需要帮助？ ⬇️**

使用右下角的**蓝色** **聊天气泡**。

或尝试**AI聊天**（来自搜索框）以快速获取答案。
:::

:::LinkArrayItem{headerType="IMAGE" headerImage="https://api.archbee.com/api/optimize/K_JWZranXy1tD6qvlG2v6-MS_ubDHlXgoktt4svD2rL-20250911-192619.png"}
:FontAwesome[]{icon="fa-solid fa-hand-holding-heart"}**&#x20;  您的意见很重要**

使用下面的反馈表，匿名提交。

或在**Q\&A 区域**中提问，我们的团队或 AI 会为您提供解决方案。
:::
::::

