我有一个非常简单的排序功能,通过index
排序对象:排序功能在IE浏览器不工作11
panoramas.sort((a, b) => {
if (a.index > b.index) return 1
})
输入:
[
{ index: 0 },
{ index: 2 },
{ index: 1 }
]
输出:
[
{ index: 1 },
{ index: 2 },
{ index: 3 }
]
功能适用于Chrome和Firefox,但不适用于IE(阵列根本没有分类)
我的功能有问题吗?
我想* *它不排序,因为你的函数的情况下'没有明确的返回值a.index <= b.index'。 –
@MartinNyolt我应该如何更改代码以反映这一点? – alex
请参阅[此答案](http://stackoverflow.com/a/24080786/1314743)。 –