如何在React Native视图中呈现数学方程式?对于Web应用程序,我们可以使用LaTex或MathJax解决方案。但是,React Native渲染本地组件。使用WebView不好,因为每个WebView组件的MathJax加载需要时间。
我们如何在React Native视图(非WebView)上呈现数学方程式?
SVG
,因此您可以尝试生成SVG,然后在React Native中进行渲染(我非常确定它不会直接运行,但至少是一种方法)。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}
/>