【问题标题】:Displaying a string representing HMTL as actual HTML, not string content in F#'s Fable application将表示 HMTL 的字符串显示为实际 HTML,而不是 F# 的 Fable 应用程序中的字符串内容
【发布时间】:2020-02-05 05:30:33
【问题描述】:

正如标题所暗示的,我想显示一个代表一些有效 HTML 的字符串作为该字符串所代表的实际元素,而不是输出字符串内容。

示例:给定 字符串 This <b>is</b> a <em>string</em> representing HTML,我想在显示器上看到:这个 是 字符串 代表 HTML

我在其他地方询问并得到了关于 unSafeInsideHTML 的答案,这是 Fable 绑定到的 React 指令。
事情是我也在网上阅读了 React 的 Fragment 指令,据说它更安全。不过,我无法理解如何使用 Fable 中的 Fragment 指令。

那么,是否可以从 Fable 中使用 Fragment ?如果有,怎么做?

【问题讨论】:

    标签: html reactjs f# fable-f# safe-stack


    【解决方案1】:

    不知道为什么将您正在创建的 html 元素包装在片段中会使它们更安全,但这就是您使用 F#/Fable 中的 Reacts Fragments 的方式。

    let view model dispatch =
      fragment [ FragmentProp.Key "some key" ] [ 
        td [ ] [ str "1" ]
        td [ ] [ str "1" ]
        td [ ] [ str "1" ]
      ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-03
      • 1970-01-01
      • 1970-01-01
      • 2018-06-22
      相关资源
      最近更新 更多