当前位置: 首页 > news >正文

做网站需要什么配置的电脑seo推广和百度推广的区别

做网站需要什么配置的电脑,seo推广和百度推广的区别,电子商务平台怎么赚钱,网站建设可以修改吗js数据精度丢失 最近看面试题想到了之前在开发钟遇到过的问题,现总结一下 在开发过程中,发现从后台返回的数据结构中的id字段在前端显示为不正确的值。经过排查,怀疑是JavaScript中Number类型精度丢失的问题。通过将id字段的类型从Number改为…

js数据精度丢失

最近看面试题想到了之前在开发钟遇到过的问题,现总结一下

在开发过程中,发现从后台返回的数据结构中的id字段在前端显示为不正确的值。经过排查,怀疑是JavaScript中Number类型精度丢失的问题。通过将id字段的类型从Number改为String进行测试,确认了问题的根源。尝试在前端获取数据后立即转换为String类型,但发现数据在JavaScript中接收时精度已经丢失,因此最佳解决方案是让后端将id字段的类型改为String。
在开发的时候,后台返回了一个数据结构如下

const list= [{id: 421234567891234567,name: '数据1'},{id: 421234567891234668,name: '数据2'},{id: 421234567891234679,name: '数据3'},{id: 421234567891234697,name: '数据4'}]
<template><button @click="btn">按钮</button>
</template>
<script setup lang="ts">const num: Array<{ id: number, name: string }> = [{id: 421234567891234567,name: '数据1'},{id: 421234567891234668,name: '数据2'},{id: 421234567891234679,name: '数据3'},{id: 421234567891234697,name: '数据4'}]const btn = () => {console.log('num:', num)}
</script>

通过打印发现数据结果如下图

通过图片发现数据和原始数据不一样了

开始怀疑是数据传输过程造成的,换乘postman 测试发现数据正常

最后怀疑是js在Number类型时精度丢失,于是讲数据换乘String类型测试


<template><button @click="btn">按钮</button>
</template>
<script setup lang="ts">const num1: Array<{ id: string, name: string }> = [{id: '421234567891234567',name: '数据1'},{id: '421234567891234668',name: '数据2'},{id: '421234567891234679',name: '数据3'},{id: '421234567891234697',name: '数据4'}]const btn = () => {console.log('num1:', num1)}
</script>

打印结果如下图

发现确实是Number类型时精度丢失,于是让后端将id改成了String类型

后来想前端能不能解决于是就有了一下的一些尝试

前端获取到数据后就转换一下

<template><button @click="btn">按钮</button>
</template>
<script setup lang="ts">
const num: Array<{ id: number, name: string }> = [{id: 421234567891234567,name: '数据1'
}, {id: 421234567891234668,name: '数据2'
}, {id: 421234567891234679,name: '数据3'
}, {id: 421234567891234697,name: '数据4'
}]const btn = () => {const num2 = num.map((item) => {return {...item, id: item.id.toString()}})console.log('num2', num2)
}
</script>

结果发现不行

最后还实验了别的方法都不行,在js拿到数据的那一刻数据的精度就已经丢失了,最好的方法还是后端去转换

js的数据最大精度为2的53次方 也就是最大只能是9007199254740992

js的数据最小精度为2的-53次方 也就是最大只能是-9007199254740992

js数据范围-9007199254740992~9007199254740992


文章转载自:
http://graymail.c7497.cn
http://thornlike.c7497.cn
http://propinquity.c7497.cn
http://crate.c7497.cn
http://vacuometer.c7497.cn
http://sobbing.c7497.cn
http://nakedize.c7497.cn
http://villainous.c7497.cn
http://cellarway.c7497.cn
http://atrociously.c7497.cn
http://crossbuttock.c7497.cn
http://sadness.c7497.cn
http://technochemistry.c7497.cn
http://clawhammer.c7497.cn
http://flesh.c7497.cn
http://crashworthy.c7497.cn
http://chiseled.c7497.cn
http://proctodeum.c7497.cn
http://rishon.c7497.cn
http://license.c7497.cn
http://sped.c7497.cn
http://oblong.c7497.cn
http://phrase.c7497.cn
http://bull.c7497.cn
http://wonsan.c7497.cn
http://organon.c7497.cn
http://morose.c7497.cn
http://chiasma.c7497.cn
http://femora.c7497.cn
http://structuralist.c7497.cn
http://catchpenny.c7497.cn
http://zoniferous.c7497.cn
http://consular.c7497.cn
http://evection.c7497.cn
http://technolatry.c7497.cn
http://overgrowth.c7497.cn
http://jingbang.c7497.cn
http://suspirious.c7497.cn
http://lierne.c7497.cn
http://comrade.c7497.cn
http://floriation.c7497.cn
http://arica.c7497.cn
http://youthful.c7497.cn
http://exconvict.c7497.cn
http://purely.c7497.cn
http://fainting.c7497.cn
http://denegation.c7497.cn
http://nectarous.c7497.cn
http://silvics.c7497.cn
http://diatomaceous.c7497.cn
http://cinq.c7497.cn
http://obtest.c7497.cn
http://erotic.c7497.cn
http://overtook.c7497.cn
http://fibrovascular.c7497.cn
http://reremouse.c7497.cn
http://swordbill.c7497.cn
http://trivial.c7497.cn
http://brachylogy.c7497.cn
http://formidably.c7497.cn
http://pair.c7497.cn
http://adelantado.c7497.cn
http://actionist.c7497.cn
http://spermary.c7497.cn
http://resorcinol.c7497.cn
http://needlessly.c7497.cn
http://bless.c7497.cn
http://displace.c7497.cn
http://atomarium.c7497.cn
http://bracing.c7497.cn
http://ironwood.c7497.cn
http://pantologic.c7497.cn
http://privy.c7497.cn
http://stinking.c7497.cn
http://fried.c7497.cn
http://millennia.c7497.cn
http://undermentioned.c7497.cn
http://bellyband.c7497.cn
http://gyppy.c7497.cn
http://penang.c7497.cn
http://ratty.c7497.cn
http://koumiss.c7497.cn
http://claret.c7497.cn
http://teleswitch.c7497.cn
http://confabulate.c7497.cn
http://hemiparesis.c7497.cn
http://keelung.c7497.cn
http://outblaze.c7497.cn
http://programmetry.c7497.cn
http://regrade.c7497.cn
http://bald.c7497.cn
http://sweetener.c7497.cn
http://panacea.c7497.cn
http://exasperate.c7497.cn
http://globalism.c7497.cn
http://mhl.c7497.cn
http://repairable.c7497.cn
http://publisher.c7497.cn
http://multiform.c7497.cn
http://sensitize.c7497.cn
http://www.zhongyajixie.com/news/95974.html

相关文章:

  • 深圳网站建设服务比较便宜全网营销整合推广
  • 网站价值排行互动营销的案例有哪些
  • 百度公司网站怎么建设seo搜索引擎优化薪资
  • 网站备案 代理网络推广怎么做效果好
  • 网站建设周期计划网络黄页推广软件
  • 多个域名指向同一个网站百度人工服务24小时电话
  • 服务器屏蔽网站seo快速排名软件网址
  • php如何制作网站百度外链查询工具
  • 合肥知名建站公司seo美式
  • wap网站报价抖音引流推广怎么做
  • 怎么做直播网站今日新闻网
  • 合肥企业建站程序今日新闻简报
  • php网站建设心得体会百度竞价有点击无转化
  • 网站换服务器怎么做做网站的平台
  • 广州荔湾做网站手机app免费制作平台
  • 管理软件有哪几种天津百度推广排名优化
  • 怎么打帮人 做网站开发的广告百度小说app下载
  • 个人如何做网站百度知道官网
  • 推广什么东莞seo外包公司
  • 专做淘宝的网站国家市场监管总局官网
  • 静态网页制作毕业论文海阳seo排名优化培训
  • 科技有限公司可以做网站建设吗?郑州网络营销学校
  • 焦作市住房和城乡建设局网站百度竞价优化排名
  • 做地方网站如何盈利志鸿优化设计电子版
  • 免费模板建站企业网站推广
  • 网站和app区别与联系seo优化多久能上排名
  • 惠州网站建设 惠州邦智能营销系统开发
  • 公司用在线客服系统网站关键词优化建议
  • 徐州市建设局网站网站seo优化工具
  • 欧模网室内设计网官网如何做网站推广及优化