离子 2 中的 MathJS
MathJS in ionic 2
有人可以帮助我如何在 ionic 2 中使用 mathjs 吗?
就是不会导入使用,真的不知道怎么办。
在 ionic 1 中很容易加载库并使用它,但在 ionic 2 中则不然。
谢谢!
试试这个
npm install mathjs --save
npm install @types/mathjs --save-dev
在组件中:
import * as math from 'mathjs'; // don't named as Math, this will conflict with Math in JS
在某些方法中:
let rs = math.eval('cos(45 deg)');
或者您可以使用 CDN:
将此行添加到 index.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/3.9.1/math.min.js"></script>
在组件中:
// other import ....;
declare const math: any;
在某些方法中:
let rs = math.eval('cos(45 deg)');
有人可以帮助我如何在 ionic 2 中使用 mathjs 吗? 就是不会导入使用,真的不知道怎么办。
在 ionic 1 中很容易加载库并使用它,但在 ionic 2 中则不然。
谢谢!
试试这个
npm install mathjs --save
npm install @types/mathjs --save-dev
在组件中:
import * as math from 'mathjs'; // don't named as Math, this will conflict with Math in JS
在某些方法中:
let rs = math.eval('cos(45 deg)');
或者您可以使用 CDN:
将此行添加到 index.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/3.9.1/math.min.js"></script>
在组件中:
// other import ....;
declare const math: any;
在某些方法中:
let rs = math.eval('cos(45 deg)');