我正在尝试使用math.js(http://mathjs.org/docs/reference/functions/inv.html),但看不到如何将其包含在HTML文件中。
我读到您可以通过将其添加到文件中来包括它:
var math = require('mathjs');
Run Code Online (Sandbox Code Playgroud)
但这对我没有用
我意识到这听起来像是一个非常愚蠢的问题,但是我试图自己弄清楚这个问题,但没有成功。
要回答我的问题,只需显示一个成功使用math.js的完整HTML文件(不仅仅是其中的一部分代码)
谢谢
我尝试了亚历山大·奥玛拉的建议,得到了:
/** * Math.js can easily be extended with functions and variables using the * `import` function. The function `import` accepts a module name or an object * containing functions and variables. */ // load math.js (using node.js) var math = require('../index'); /** * Define new functions and variables */ math.import({ myConstant: 42, hello: function (name) { return 'hello, ' + name + '!'; } }); // defined …
Run Code Online (Sandbox Code Playgroud)