我得到了Expected SCRIPT1005:'(',在Edge上使用JavaScript,在Chrome上运行正常,为什么? [英] I got the Expected SCRIPT1005: '(' with JavaScript on Edge, with Chrome it's working fine, why?

查看:657
本文介绍了我得到了Expected SCRIPT1005:'(',在Edge上使用JavaScript,在Chrome上运行正常,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我解决了一个问题,该问题在Edge上没有兼容性,但在Chrome中却没有.因此,我使用Object.assign(a,{})代替了{... a,{}}.

I resolve a problem which was showing up no compatibility on Edge but in Chrome. So, I changed using Object.assign(a, {}) instead of {...a, {}}.

在这里,我讨论了这个先前的问题:

Here's where I discussed this previous problem: I would like to know why my website is not showing up on Edge? it's developed on JavaScript

但是,后来我又遇到了另一个错误.让我解释一下.控制台上就是这个:SCRIPT1005:预期为'('. 此错误仅出现在Edge浏览器上.

But, later I got another error. And let me explain you. It's this one on the console: SCRIPT1005: Expected '('. This error appears just on Edge browser.

main.load = function (page) {
    function getClass(className) {
        return Function('return ' + className)();
    }

    return new Promise((resolve, reject) => {
        try{
            new getClass(page); 
        }catch{ // Here's the: SCRIPT1005: SCRIPT1005: Expected '('; error.
            var count = 0;
            let script = dom("script",document.createElement("div"));
            script.src = `src/pages/${page}/${page}.js`;

            document.body.appendChild(script);
            return;
        }
        resolve(getClass(page));
    });
}```

I'm trying to look for a way to change some promises and try and catch that are wrapping the line the error is telling me on the console that is wrong.

```try{javascript
            new getClass(page); 
        }catch{ // Here's the: SCRIPT1005: SCRIPT1005: Expected '('; error.
            var count = 0;
            let script = dom("script",document.createElement("div"));
            script.src = `src/pages/${page}/${page}.js`;

            document.body.appendChild(script);
            return;
        }```

SCRIPT1005: Expected '('

推荐答案

要解决此问题,只需将要处理错误输出的参数添加到catch语句中.这意味着Edge需要知道您正在正确地处理错误.

To fix this is just about adding the parameter to deal with errors outputs into the catch statement. What this means is that Edge needs to know you are dealing with the error correctly.

因此,我添加了:

     catch (err){}

一切正常!

这篇关于我得到了Expected SCRIPT1005:'(',在Edge上使用JavaScript,在Chrome上运行正常,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆