【问题标题】:MathJS in ionic 2离子 2 中的 MathJS
【发布时间】:2017-02-11 06:51:50
【问题描述】:

有人可以帮我如何在 ionic 2 中使用 mathjs 吗? 就是不导入使用,真的不知道怎么办。

在 ionic 1 中,加载和使用库很容易,但在 ionic 2 中则不然。

谢谢!

【问题讨论】:

    标签: ionic2 mathjs


    【解决方案1】:

    试试这个

    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)');
    

    【讨论】:

    • 您也可以对其他第 3 方库执行此操作。
    猜你喜欢
    • 2017-09-27
    • 2017-01-19
    • 1970-01-01
    • 2016-09-30
    • 1970-01-01
    • 2016-12-27
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多