【发布时间】:2017-02-11 06:51:50
【问题描述】:
有人可以帮我如何在 ionic 2 中使用 mathjs 吗? 就是不导入使用,真的不知道怎么办。
在 ionic 1 中,加载和使用库很容易,但在 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)');
【讨论】: