【问题标题】:How to display Math equations in React Native View如何在 React Native View 中显示数学方程式
【发布时间】:2019-09-27 17:44:34
【问题描述】:

如何在 React Native Views 中渲染数学方程式?对于 Web 应用程序,我们可以使用 LaTex 或 MathJax 解决方案。但是 React Native 渲染的是原生组件。使用 WebView 会很糟糕,因为每个 WebView 组件的 MathJax 加载都需要时间。 我们如何在 React Native Views(非 WebView)上渲染数学方程?

【问题讨论】:

  • 伙计们到现在还没有解决办法,我也想要这个答案
  • 您找到合适的解决方案了吗?
  • @suman 你能找到解决办法吗?
  • 没有。我没有找到解决方案。

标签: react-native


【解决方案1】:

MathJax 允许您使用渲染 SVG,因此您可以尝试生成 SVG,然后在 React Native 中渲染它(我很确定它不会开箱即用,但至少它是一种方式)

【讨论】:

    【解决方案2】:

    React Native 中有一个 MathJax 库。库有时无法正常工作,但您应该尝试一下。 https://github.com/calvinkei/react-native-mathjax#readme

    用法

    <MathJax
      // HTML content with MathJax support
      html={'$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$<br><p>This is an equation</p>'}
      // MathJax config option
      mathJaxOptions={{
        messageStyle: 'none',
        extensions: [ 'tex2jax.js' ],
        jax: [ 'input/TeX', 'output/HTML-CSS' ],
        tex2jax: {
          inlineMath: [ ['$','$'], ['\\(','\\)'] ],
          displayMath: [ ['$$','$$'], ['\\[','\\]'] ],
          processEscapes: true,
        },
        TeX: {
          extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js']
        }
      }}
      {...WebView props}
    />
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-08
    • 2011-07-20
    • 2020-09-08
    • 1970-01-01
    • 2021-02-05
    • 1970-01-01
    相关资源
    最近更新 更多