我试图用Mathquill做一些简单的静态格式化。当我测试我的代码时,文本没有格式化,也没有任何错误让我知道我是否做错了什么。
<html>
<head>
<style>
<link rel="stylesheet" href="dist/mathquill/mathquill.css"/>
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="dist/mathquill/mathquill.js"></script>
<script>
var MQ = MathQuill.getInterface(2);
var problemSpan = document.getElementById('problem');
MQ.StaticMath(problemSpan);
</script>
</head>
<body>
<p>Solve <span id="problem">ax^2 + bx + c = 0</span>.</p>
</body>
</html>
所有路径都是正确的,因为没有404错误。
样式标签不需要,并且干扰了链接标签。 需要等DOM准备好。
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.10.1/mathquill.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathquill/0.10.1/mathquill.js"></script>
<script>
window.addEventListener('DOMContentLoaded', () => {
var MQ = MathQuill.getInterface(2);
var problemSpan = document.getElementById('problem');
MQ.StaticMath(problemSpan);
});
</script>
</head>
<body>
<p>Solve <span id="problem">ax^2 + bx + c = 0</span>.</p>
</body>
</html>