我原本希望(10000).toLocaleString('de-DE')
返回"10.000"
,而是获得"10000"
。
有没有理由不支持这个?是否有更好的数字格式化方法?
答案 0 :(得分:1)
这是一个webkit问题,PhantomJS不想保持国际化......所以不幸的是,我们在一段时间内坚持这个问题。
https://github.com/ariya/phantomjs/issues/12581
我最终做的是编写一个自定义匹配器来检查两者,因为我在Chrome和PhantomJS中运行。
jasmine.addMatchers({
isAnyOf: (util, customEqualityTesters) => {
return {
compare: (actual, expected) => {
let result = {};
for (let expect of expected) {
console.log(actual == expect);
if (expect == actual) {
result.pass = true;
return result;
}
}
result.pass = false
return result;
}
}
}
})
然后你可以像
一样使用它expect(actual).isAnyOf(['10000', '10.000']);