关于intl在个别环境里报错的一种解决方案
之前也是和很多人同样遇到INTL的报错,查询了一番INTL国际化在某些环境里不被支持,但是也有解决方案,一般情况下,intl的使用是在一些插件或引擎里,我们只需要找到代替intl的方案即可。例如我在我的库里找到关于intl的这段格式化后的代码: Sc.graphemeSegmenter = function() {
if ("function" == typeof(null == Intl ? void 0 : Intl.Segmenter)) {
var t = new Intl.Segmenter;
return function(e) {
return h(t.segment(e))
.map((function(t) {
return t.segment
}))
}
}
return function(t) {
return h(t)
}
}()
///我们只需要找到intl的替代方案即可
//修改后的代码
Sc.graphemeSegmenter = function() {
return function(n) {
return h(function(n) {
const t = [];
let e = 0;
for (; e < n.length;) {
const o = n.codePointAt(e);
t.push(String.fromCodePoint(o)), e += o > 65535 ? 2 : 1
}
return t
}(n))
}
}()