7

我决定在我的一个 Web 项目中使用 mathjax,但遇到了一个我无法理解的问题。

第一点:我已经创建了自己的 CDN 网站,我在一些 url 上安装了 2.0 版本的 mathjax,例如:“http://mathjax.example.com”。

我的 web 应用程序是在 asp.net mvc3+razor 中开发的,在我决定创建一个 cdn 网站之前,我使用的是标准脚本,它运行良好:<script type="text/javascript" src="http:/ /cdn.mathjax.org/mathjax/1.1-latest/MathJax.js"></script>

但是,外部 CDN 不能满足我的客户目的,因此我必须在同一台服务器上创建一个 CDN 网站。

好吧,我已经下载了 zip 文件并安装在我的网络服务器上提供的目录中。

我的问题是,如果我将旧网址指向新网址:它不起作用,最后我的浏览器左下角有一条消息“文件加载失败:/extensions/MathZoom.js”

在某处有必要进行一些配置吗?

4

3 回答 3

2

这可能是由于两个原因

1.您可能还没有解压整个 zip 文件夹,所以请先解压。

仍然你得到错误调查第二个原因。

2.您没有正确引用该文件。 例如:

<script type ="text/javascript" src="pathto\mathjax.js">

您输入了错误的文件名。文件的正确名称是 MathJax.js。下面给出的是正确的方法。

<script type ="text/javascript" src="pathto\MathJax.js">

MathJax.js 是提取文件夹中的文件名(除非修改)

如果所有这些都不起作用,那么以这种方式链接到脚本:

<script type="text/javascript" src="Pathto/MathJax.js?config=TeX-AMS-MML_HTMLorMML">

您的脚本不起作用的原因是您不包括:

'?config=TeX-AMS-MML_HTMLorMML'

于 2014-07-29T08:13:57.577 回答
2

Likely, MathJax fails to detect its own root directory against which additional files urls are resolved, or you actually miss the extensions folder.

Something that I got bitten by: the main MathJax javascript file can't be renamed - it MUST stay "whateverpath/MathJax.js". Renaming it and trying to load got me exactly the error you mentioned, by failing to detect the root path "whateverpath".

Also, you obviously need to deploy the whole package, not just the MathJax main js file.

Finally, I notice you used the 1.1 version on the CDN, and said you deployed 2.0. Is this on purpose?

Hope that helps.

于 2012-11-15T17:30:24.023 回答
1

我想将 MathJax 库捆绑到我的生产 main.min.js 文件中。我的想法是将它与 Gulp 一起使用,但没有成功。

在我看来,MathJax.js 的依赖项遍布 mathjax 目录。我什至无法将该配置脚本片段分离到单独的文件中(可能是因为该类型:type="text/x-mathjax-config")。

然后,如果没有该配置参数,我什至无法使用 mathJax 脚本标签:?config=TeX-AMS-MML_HTMLorMML。这不起作用:

<script type="text/javascript" src="path/to/MathJax.js"></script>

这行得通。它是 CDN。目前我仍在使用此代码:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    "HTML-CSS": {
        preferredFont: "STIX",
        linebreaks: { automatic: true, width: "53%" }
    }
});

<script type="text/javascript"
        src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

对我来说,MathJax 文档是一团糟。如果有人解决这个问题,我将不胜感激。

于 2015-06-12T13:35:10.027 回答