处理后台返回的数据
wow Larissa
这个作者很懒,什么都没留下…
展开
-
三元表达式(多条件)
item.status == 1 ? '审批中' : item.status == 2 ? '审批通过' : item.status == 3 ? '拒绝':'未提交'原创 2021-12-09 16:56:12 · 1430 阅读 · 0 评论 -
如何处理后端接口返回字符串里面含有标签问题
js之去掉字符串中的标签在这里插入代码片// 已知变量及对应的值let str = '<div><p>1233451</p></div>'// 用replace方法及正则表达式实现let res =str.replace(/<.*?>/ig,"")console.log('结果',res)...原创 2021-10-12 14:10:00 · 1088 阅读 · 0 评论 -
处理接口返回的数据,把后端返回的字段,修改成自己想要的
const jsona = JSON.stringify(res.data) // 把接口返回的res.data数据转成字符串// console.log(jsona);const jsonb = jsona.replace(/"Code"/g, '"value"') // 修改成你要的字段const jsonc = jsonb.replace(/"Name"/g, '"label"')const endjson = JSON.parse(jsonc) // 把JSON 字符串转换成对象..原创 2021-06-09 14:24:19 · 3716 阅读 · 0 评论 -
String类型转json格式
拿到下面这种格式的数据,我们是无法直接用的需要转化一下1.String类型转json格式通过JSON.parse进行转换如下:const goosid = JSON.parse(curid.bookIds) 最终得到下图数据:2.把json转换成String型通过JSON.stringify进行转换如下const good = JSON.stringify(goosid)最终得到下图数据:...原创 2021-01-12 16:32:49 · 9846 阅读 · 0 评论 -
javascript 对后台返回的数据进行分类,筛选一样的数据
模拟后台返回的数据为:var arr = [ {personName:"张三",id:1,age:12,gender:"male"}, {personName:"张三",id:1,age:12,gender:"male"}, {personName:"张三",id:1,age:12,gender:"male"}, {personName:"李四",id:1,age:12,gender:"male"}, {personName:"李四",id:1,age:12,gen转载 2020-09-01 17:01:38 · 1295 阅读 · 0 评论