vue项目中使用 mathjs(精度计算问题)
文章目录
1、安装
cnpm install mathjs --save
2、main.js中引入
import * as math from 'mathjs' // 新版本需要这样引入 感谢评论区的指出
Vue.prototype.$math = math3、使用
this.$math.round(3.1415926, 3) // 四舍五入保留3位小数4、使用文档
https://mathjs.org/docs/refer...
存在问题
本地调试没有问题,发布线上以后报错
Uncaught SyntaxError: In "GeV^-2", "^" must be followed by a floating-point number解决方法:固定版本 "mathjs": "8.1.0"

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论