vue 中显示带有 latex 数学语法的 html 内容的方案 - V2EX
zxCoder

vue 中显示带有 latex 数学语法的 html 内容的方案

  •  
  •   zxCoder Jan 28, 2021 1268 views
    This topic created in 1930 days ago, the information mentioned may be changed or developed.

    查了好多也没找到有效的做法

    后台获取到的是一个字符串,是 html 格式,然后里面带有一些 latex 公式,例如

    "Then, Mikaela will count and give you the number of pairs of vertices $$$(s, t)$$$ where $$$s \in S$$$ and $$$t \in T$$$ such that the simple path from $$$s$$$ to $$$t$$$ contains $$$v$$$.</p><p>Mikaela the Goddess is busy and will be available to answer at most $$$11\,111$$$ questions.</p><p>This is your only chance. Your task is to determine the tree and report its edges.</p>" 

    用 vue 的 v-html 可以直接展示 html,但是其中的 latex 公式不知道要怎么办,网上找的几种 mathjax 的方法都不好用而且很麻烦

    Supplement 1    Jan 29, 2021

    怀疑人生 一开始还感觉这应该是个很正常的需求,结果面向搜索引擎编程失败。。。

    Supplement 2    Jan 29, 2021

    已解决!

    后台把html标签里的那些latex公式替换成svg图片,然后前端直接展示html就行

    用的这个网站的api

    https://private.codecogs.com/eqneditor/integration/htmlequations.php

    2 replies    2021-01-29 00:21:39 +08:00
    iConnect
        1
    iConnect  
       Jan 29, 2021 via Android
    你试下 $nextTick 方法,一定要让数据加载完之后再让 mathjax 渲染 LaTeX,mathjax 提前渲染了这时 v-html 数据还没加载完就无效果了
    XiaoxiaoPu
        2
    XiaoxiaoPu  
       Jan 29, 2021
    找到一个应该可以用的 mathjax vue 封装 github.com/justforuse/vue-mathjax
    About     Help     Advertise     Blog     API     FAQ     Solana     5230 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 33ms UTC 03:49 PVG 11:49 LAX 20:49 JFK 23:49
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86