我正在使用离子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')
答案 0 :(得分:0)
您可以在index.html
内添加脚本
<script src="path/to/math.js"></script>