javascript - 带有时刻 js 的时区选择器在 IE11 中不起作用
问题描述
//TimeZone
/*const z_t = (s) => {
if (i18n !== void 0 && i18n[s]) {
return i18n[s];
}
return s;
};*/
const z_t = function(s) {
if (i18n !== void 0 && i18n[s]) {
return i18n[s];
}
return s;
};
const timezones = [
"Etc/GMT+12",
"Pacific/Midway",
"Pacific/Auckland",
"Pacific/Tongatapu",
];
const i18n = {
"Etc/GMT+12": "International Date Line West",
"Pacific/Midway": "Midway Island, Samoa",
"Pacific/Honolulu": "Hawaii",
"Pacific/Tongatapu": "Nuku'alofa",
};
const selectorOptions = moment.tz
.names()
.filter((tz) => {
return timezones.includes(tz);
})
.reduce((memo, tz) => {
memo.push({
name: tz,
offset: moment.tz(tz).utcOffset(),
});
return memo;
}, [])
.sort((a, b) => {
return a.offset - b.offset;
})
.reduce((memo, tz) => {
const timezone = tz.offset ? moment.tz(tz.name).format("Z") : "";
return memo.concat(
`<option value="${tz.name}">(GMT${timezone}) ${z_t(tz.name)}</option>`
);
}, "");
let js_Selector = document.querySelector(".js-Selector");
console.log(js_Selector);
if (js_Selector) {
js_Selector.innerHTML = selectorOptions;
js_Selector.value = "Europe/Brussels";
const event = new Event("change");
js_Selector.dispatchEvent(event);
}
$(".js-Selector").select2();
我正在使用带有时刻 js 的时区选择器来选择时区。它工作正常,但在 IE11 上它不起作用。它的 bcoz 中有一些箭头功能。我尝试更正但它不起作用。因为我是新手请帮忙我来解决这个问题。无论如何,提前感谢您的帮助
解决方案
推荐阅读
- swift - 以起始接触点画一条直线
- python - 无法将字符串转换为浮点数:'Neudorf'
- powershell - Powershell:从字符串(11/11/2020 11:23:45 Text2 12345)中提取日期时间而不使用正则表达式
- cocoa - NSImageView 72dpi 图像在 HiDPI 显示器上模糊
- r - 如何使用 R 中的 glm 在二元逻辑回归中创建循环以包含混杂因素(协变量)?
- python - 我需要比较python中的2个嵌套列表以查找第一个列表的字符串与第二个列表中的字符串不匹配的位置
- flutter - 我们可以使用 apache kafka 作为后端构建 Flutter 移动聊天应用程序吗?
- vue.js - 在 VUE 中使用 Konva 用鼠标移动绘制矩形
- c++ - 关于多线程时的竞争条件的问题
- reactjs - ReactJS 在开始加载页面时删除所有信息