• 简体中文
  • 自定义配置

    基本用法与 React 相同。表中链接指向各参数的完整说明,下方补充 Taro 的 style 用法。

    属性类型默认值与用途
    textstring必填,当前完整 Markdown。
    streamingboolean | StreamingConfigfalse,控制末尾修复、平滑输出和效果。
    buildBaseBuildConfig{},选择公式、脚注等解析能力。
    themeTheme'light',主题预设或局部覆盖,见样式指南。
    pluginsIPluginItem | IPluginItem[][],扩展 Taro 预设;Raw 入口必填。
    patchesIPatchItem<ReactNode>[][],用 Taro 组件替换或插入指定文本。
    classNamestringundefined,添加到最外层 View 的类名。
    stylestring | CSSPropertiesundefined,最外层 View 的样式对象或字符串。
    refRef<FluxdownRef>undefined,读取响应式渲染结果,不是视图引用。
    导入方式

    BaseBuildConfig、StreamingConfig、Theme 和 FluxdownRef 从 @fluxdown/taro 导入;IPluginItem 从 @fluxdown/react-base-plugins/typings 导入;IPatchItem 从 @fluxdown/core 导入;CSSProperties、ReactNode 和 Ref 来自 react。

    style 可选

    类型: string | CSSProperties

    默认值: undefined

    最外层 Taro View 的样式,沿用 Taro style 属性的用法,支持对象或 CSS 声明字符串。也可以通过 className 使用应用中的样式:

    <Fluxdown
      className="conversation-message"
      style={{ padding: '16px', maxWidth: '720px' }}
      text={text}
    />

    同样的样式也可以写成字符串:

    <Fluxdown style="padding: 16px; max-width: 720px" text={text} />

    内容内部的颜色与排版见样式指南。

    组件与插件

    调整组件或交互时,在 Slot 插件或 patch 的 render 函数中返回 Taro 组件。

    Full 与 Lite 包含不同的 Taro 插件,具体见插件矩阵。Full 使用 Prism 高亮代码。公式先尝试通过 Taro RichText 展示 KaTeX 输出,失败时改用 Taro Image 展示 MathJax SVG,仍无法渲染时保留源码。实际呈现遵循目标平台对富文本和 SVG 图片的支持。