如何解决IE控制台错误:SCRIPT438:对象不支持属性或方法“来自”
我的网站上有一个函数,该函数接收一系列电子邮件字符串并删除所有重复项。但是它不起作用,即因为我使用了Array.from方法。如何转换为以下代码以在ie上工作?
let emailsListArray = ['reece@gmail.com','someone@gmail.com','another@gmail.com','reece@gmail.com','person@gmail.com','another@gmail.com'];
Array.prototype.unique = function() {
return Array.from(new Set(this));
}
emailsListArray = emailsListArray.unique();
console.log(emailsListArray);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
解决方法
Set方法也没有完全支持,即您有2个解决方案:
1:只需使用与所有导航器兼容的数组方法:例如,您可以使用以下代码:
let shutdown = JSON.parse(rawdata);
if(message.member.roles.cache.find(r => r.id === admin_role)) {
if(shutdown.shutdown){
let LockedWrite = {"shutdown": false};
fs.writeFileSync("shutdown.json",JSON.stringify(LockedWrite,null,2),finished);
message.channel.send("Please wait up to 30 seconds to update the channels")
//Changing server config,can take several seconds
try{
async function asyncCall() {
const channel1 = await guild.roles.cache.get(rawchannels[0])
const channel2 = await guild.roles.cache.get(rawchannels[1])
const channel3 = await guild.roles.cache.get(rawchannels[2])
const channel4 = await guild.roles.cache.get(rawchannels[3])
const channel5 = await guild.roles.cache.get(rawchannels[4])
const channel6 = await guild.roles.cache.get(rawchannels[5])
const channel7 = await guild.roles.cache.get(rawchannels[6])
channel1.overwritePermissions([
{
id: nivelesroles[3],allow: ["SEND_MESSAGES"]
},{
id: nivelesroles[4],allow: ["VIEW_CHANNEL"]
}
])
channel2.overwritePermissions([
{
id: nivelesroles[3],allow: ["VIEW_CHANNEL"]
}
]) //and so on
2:将polyfill文件添加到项目中,您可以在此处找到array的示例。 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。