> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

## If 组件的产品和版本属性

`<If>` 组件现在支持 `products` 和 `versions` 属性，允许您根据页面在导航结构中的位置有条件地显示内容。

**`Markdown`**

```jsx Markdown
<If products={["api-reference"]}>
  此内容仅在 api-reference 产品中显示
</If>

<If versions={["v2", "v3"]}>
  此内容仅在 v2 或 v3 中显示
</If>

<If products={["docs"]} versions={["v2"]}>
  所有条件必须匹配（AND 逻辑）
</If>
```

您还可以使用 `not` 属性来反转条件，当当前产品或版本不匹配时显示内容。

阅读文档