代码之家  ›  专栏  ›  技术社区  ›  Gaudam Thiyagarajan

Mathjax offline for web view

  •  5
  • Gaudam Thiyagarajan  · 技术社区  · 6 年前

    通过将mathjax cdn链接到react native,使用webview呈现数学内容是很常见的。但如何解决使其离线的问题。

    1. 有没有办法在本地维护该捆绑包?

    2. 它更受欢迎吗?

    3. 包裹的大小是多少?我不希望我的应用程序大小超过10mb。

    1 回复  |  直到 6 年前
        1
  •  4
  •   Gaudam Thiyagarajan    5 年前

    从下载mathjax

    http://docs.mathjax.org/en/latest/installation.html

    进入=>android/app/src/main/assets/

    现在,在webview html代码集中,脚本引用

    <script src="file:///android_asset/MathJax/MathJax.js?config=TeX-MML-AM_CHTML"></script>
    

    以及html中必要的配置。 还要确保将基本url设置为文件夹名称。

    <WebView source={{ html, baseUrl: 'file:///android_asset/MathJax/' }} />
    

    你也可以 https://github.com/mathjax/MathJax-grunt-cleaner 通过删除不需要的字体和格式来减少Mathjax资产的大小。