一、先看效果图

将浮点数原样输出,保证精确值

js 保持浮点数(经纬度)精确的浮点数位数

二、代码截图

js 保持浮点数(经纬度)精确的浮点数位数

三、代码

   mounted(){

          console.log(that.parseFloatNum('123.123456789'),'hha') 

  },

   methods:{

            parseFloatNum(x) {

                let xFloat =[]

                 xFloat = x.toString().split('.')[1]

                return Number.parseFloat(x).toFixed(xFloat.length)

              }

   }

四、用途

 原样保留经纬度坐标值等浮点类型的数据

相关文章:

  • 2021-11-14
  • 2021-12-27
  • 2022-01-28
  • 2021-11-18
  • 2021-08-24
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
猜你喜欢
  • 2021-10-13
  • 2021-09-06
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案