我正在使用Ionic 2 Beta,并尝试制作一个简单的计算器进行学习。我想使用该math.js
库(http://mathjs.org),但是我不知道如何导入此文件以在我的打字稿代码中使用它。
例如:
export class HomePage
{
constructor() {}
calculate()
{
// Here I want to use math.js
}
}
我尝试了以下方法:
export class HomePage
{
var m = require('path/to/math.js');
constructor() {}
calculate()
{
m.math.parse(expression); // assuming expression is defined
}
}
但是我得到了错误 undefined is not an object (evaluating 'm.math.parse')
您可以index.html
像这样添加脚本
<script src="path/to/math.js"></script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句