胖蔡说技术
随便扯扯

前端Latex 表达式不能正常显示

e681337914c5397-1

 

<form name="checkListForm">
    <input type="text" name="checkListItem"/>
</form>
<div id="button">Add!</div>
<br/>
<div class="list"></div>
    <script>
        $(document).ready(function(){
           $('#button').click(function(){
           var toAdd = $('input[name=checkListItem]').val();
           $('.list').append('<img src="http://latex.codecogs.com/gif.latex?\frac{x}  {y}"/>');

        }); 
         $(document).on('click', '.item', function(){
            $(this).remove();
         });
      });
    </script>

 

如上的代码,我在表格中通过按钮点击使用latex转化成图片的api, 但是我得到了这个我正在使用这个lates 表达式文件形式的codecogs文件:codecogs.com/latex/htmlequations.php

解决方法

在api请求参数上添加行转义符 ‘\’

$('.list').append('<img src="http://latex.codecogs.com/gif.latex?\frac{x}{y}"/>');

所以,我们需要把代码改成:

$('.list').append('<img src="http://latex.codecogs.com/gif.latex?\\frac{x}{y}"/>');

 

 

 

 

 

 

赞(0) 打赏
转载请附上原文出处链接:胖蔡说技术 » 前端Latex 表达式不能正常显示
分享到: 更多 (0)

请小编喝杯咖啡~

支付宝扫一扫打赏

微信扫一扫打赏