Skip to content
Mintlify
Mintlify
组件

视图

使用 view 组件为不同编程语言、框架或配置方案创建可切换的内容面板。

使用 View 组件来创建会根据多视图下拉菜单中所选视图而变化的内容。这对于展示面向不同编程语言或框架的代码示例或特定文档特别有用。

每种语言在每个页面上只使用一个 View 组件。对于因语言不同而步骤不同的操作流程,请使用 tabs;对于因语言不同而代码不同的示例,请使用 code groups

只有在选择 JavaScript 时才会显示此内容。

console.log("Hello from JavaScript!");
JavaScript and Python views
<View title="JavaScript" icon="js">
  仅在选择 JavaScript 时显示此内容。

  ```javascript
  console.log("Hello from JavaScript!");
  ```
</View>

<View title="Python" icon="python">
  仅在选择 Python 时显示此内容。

  ```python
  print("Hello from Python!")
  ```
</View>

目录会自动更新,仅显示当前选中的视图中的标题。当你使用多视图下拉菜单在不同视图之间切换时,目录会刷新为该视图显示相应的标题。

如果每个视图中的标题结构不同,用户只会看到与其所选语言或框架相关的标题。

titlestringrequired

用于标识此视图的标题。必须与多视图下拉菜单中的某个选项一致。

iconstring

一个 Font Awesome icon、Lucide icon、指向 icon 的 URL,或指向 icon 的相对路径。

iconTypestring

仅用于 Font Awesome 图标:取值为 regularsolidlightthinsharp-solidduotonebrands 之一。

Was this page helpful?Suggest editsRaise issue