小程序客户端对数据调用 sort 显示结果不正确
发布于 6 年前 作者 xyu 11919 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

对一个数组中的对象进行排序,得到的排序结果不正确

需求:数组中元素按 库存, 价格, id 排序

list: [ {id: 1, list:[ { stock: 99, cost: 98 } ]} , {id: 2, list:[ { stock: 0, cost: 98 } ]} , {id: 3, list:[ { stock: 99, cost: 21 } ]} ]

  • 预期表现

排序后结果为   3 1 2

  • 复现路径

https://developers.weixin.qq.com/s/BCzqWJmj7H9F

  • 提供一个最简复现 Demo

https://developers.weixin.qq.com/s/BCzqWJmj7H9F

  • 当前 Bug 的表现(可附上截图)

对一个数组中的对象进行排序,工具中__得到的排序结果不正确,  而__js本地 运行与真机实际运行结果保持一致且正确

需求:数组中元素按 库存, 价格, id 排序

list: [ {id: 1, list:[ { stock: 99, cost: 98 } ]} , {id: 2, list:[ { stock: 0, cost: 98 } ]} , {id: 3, list:[ { stock: 99, cost: 21 } ]} ]

  • 预期表现

排序后结果为   3 1 2

  • 复现路径

https://developers.weixin.qq.com/s/BCzqWJmj7H9F

  • 提供一个最简复现 Demo

https://developers.weixin.qq.com/s/BCzqWJmj7H9F

1 回复

测试真机跟工具变现是一致的

回到顶部