> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJhNDI3YjA0Yy0xODVjLTQ4NDEtOWRlZi0xOTlhMGE1YWJiZWIiLCJleHAiOjE3NzgyNjQyODUsImlhdCI6MTc3ODI2Mzk4NX0.xw7pmBHMqwe92S5RVwU37zKvrhgfJSCltqm-vHTZ1Rk
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# Anchor

> 为段落、表格和其他无标题内容创建可链接的锚点

`<Anchor>` 组件为段落、表格和代码块等特定内容创建直接链接。当您需要引用不会自动生成链接的非标题内容时，请使用锚点。

<Note>
  标题会根据其文本内容自动生成锚点链接，因此您无需对标题使用锚点组件。
</Note>

## 使用方法

用 `<Anchor>` 标签包装您的内容并为其分配一个自定义锚点 ID，您可以使用井号符号在 URL 中链接到该锚点（示例：`https://website.com/page#data`）。

<div>
  <div>
    <Anchor id="data">这句话有一个名为 `#data` 的自定义锚点</Anchor>。您可以通过此 URL 访问它：[https://buildwithfern.com/learn/docs/writing-content/components/anchor#data。](https://buildwithfern.com/learn/docs/writing-content/components/anchor#data。)
  </div>
</div>

```jsx Markdown
<Anchor id="data">这句话有一个名为 `#data` 的自定义锚点</Anchor>。您可以通过此 URL 访问它：https://buildwithfern.com/learn/docs/writing-content/components/anchor#data。
```

## 变体

### 锚点表格

<div>
  <div>
    <Anchor id="api-endpoints">
      | 端点            | 方法   | 描述     |
      | ------------- | ---- | ------ |
      | `/plants`     | GET  | 检索所有植物 |
      | `/plants/:id` | GET  | 检索特定植物 |
      | `/plants`     | POST | 创建新植物  |
    </Anchor>

    <p>
      您可以直接链接到 

      [API 端点表格](#api-endpoints)

      。
    </p>
  </div>
</div>

```jsx Markdown
<Anchor id="api-endpoints">

| 端点 | 方法 | 描述 |
|----------|--------|-------------|
| `/plants` | GET | 检索所有植物 |
| `/plants/:id` | GET | 检索特定植物 |
| `/plants` | POST | 创建新植物 |

</Anchor>

您可以直接链接到 [API 端点表格](#api-endpoints)。
```

### 锚点代码块

<div>
  <div>
    <Anchor id="example-code">
      ```python
      def water_plant(plant_id, amount):
          """Water a plant with specified amount"""
          headers = {"Authorization": f"Bearer {api_key}"}
          return requests.post(f"https://api.example.com/plants/{plant_id}/water", 
                              json={"amount": amount}, 
                              headers=headers)
      ```
    </Anchor>

    在您的实现中参考 [浇水代码示例](#example-code)。
  </div>
</div>

````jsx Markdown
<Anchor id="example-code">

```python
def water_plant(plant_id, amount):
    """Water a plant with specified amount"""
    headers = {"Authorization": f"Bearer {api_key}"}
    return requests.post(f"https://api.example.com/plants/{plant_id}/water", 
                        json={"amount": amount}, 
                        headers=headers)
```

</Anchor>

在您的实现中参考 [浇水代码示例](#example-code)。
````

## 属性

<ParamField path="id" type="string" required={true}>
  此内容的锚点 ID。在 URL 中使用井号引用它（示例：`#data`）
</ParamField>