创建了云对象electric后,本地安装了mathjs模块,请问我在index.obj.js如何引入mathjs
- 发布:2024-09-06 11:02
- 更新:2024-09-06 11:17
- 阅读:139
y***@163.com (作者)
// 方式一
// import {
// atan2, chain, derivative, e, evaluate, log, pi, pow, round, sqrt
// } from './node_modules/mathjs';
// 方式二
// import math from "./node_modules/mathjs"
// 方式三
// const math = require('./node_modules/mathjs/lib/browser/math.js');
// 方式四
const math = require('mathjs');
以上方式都不可以
y***@163.com (作者)
@DCloud_UNI_yuhe 如图,打印值是一个对象
{"constructor":function Decimal(v) {
var e, i, t,
x = this;
// Decimal called without new.
if (!(x instanceof Decimal)) return new Decimal(v);
// Retain a reference to this Decimal constructor, and shadow Decimal.prototype.constructor
// which points to Object.
x.constructor = Decimal;
// Duplicate.
if (isDecimalInstance(v)) {
x.s = v.s;
if (external) {
if (!v.d || v.e > Decimal.maxE) {
// Infinity.
x.e = NaN;
x.d = null;
} else if (v.e < Decimal.minE) {
// Zero.
x.e = 0;
x.d = [0];
} else {
x.e = v.e;
x.d = v.d.slice();
}
} else {
x.e = v.e;
x.d = v.d ? v.d.slice() : v.d;
}
return;
}
t = typeof v;
if (t === 'number') {
if (v === 0) {
x.s = 1 / v < 0 ? -1 : 1;
x.e = 0;
x.d = [0];
return;
}
if (v < 0) {
v = -v;
x.s = -1;
} else {
x.s = 1;
}
// Fast path for small integers.
if (v === ~~v && v < 1e7) {
for (e = 0, i = v; i >= 10; i /= 10) e++;
if (external) {
if (e > Decimal.maxE) {
x.e = NaN;
x.d = null;
} else if (e < Decimal.minE) {
x.e = 0;
x.d = [0];
} else {
x.e = e;
x.d = [v];
}
} else {
x.e = e;
x.d = [v];
}
return;
// Infinity, NaN.
} else if (v * 0 !== 0) {
if (!v) x.s = NaN;
x.e = NaN;
x.d = null;
return;
}
return parseDecimal(x, v.toString());
} else if (t !== 'string') {
throw Error(invalidArgument + v);
}
// Minus sign?
if ((i = v.charCodeAt(0)) === 45) {
v = v.slice(1);
x.s = -1;
} else {
// Plus sign?
if (i === 43) v = v.slice(1);
x.s = 1;
}
return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
},"s":1,"e":1,"d":[21,6000000]}
y***@163.com (作者)
const math = require('./node_modules/mathjs/lib/browser/math.js');
引用这个也是报错
@DCloud_UNI_yuhe
DCloud_UNI_yuhe
你看一下这个mathjs到入口文件在哪
2024-09-06 11:08