当前位置: 首页 > 工具软件 > Math.js > 使用案例 >

math.js 使用

萧和平
2023-12-01

1、安装

npm install --save mathjs

2、引入

main.js中

import { create, all } from 'mathjs'

const mathjs = create(all)

mathjs.config({

  number: 'BigNumber',

  precision: 64

})

Vue.prototype.$math = mathjs

3、使用

this.$math.evaluate(‘0.1+0.2’).toString() // 0.3  此方法不会产生科学技术法

this.$math.format(this.$math.evaluate('1000*1000')) // 1e+6 

 类似资料: