I got the Expected SCRIPT1005: '(' with JavaScript on Edge, with Chrome it's working fine, why?

眉间皱痕 提交于 2019-12-11 05:52:31

问题


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

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 '('

回答1:


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.

So, I added:

     catch (err){}

And everything worked!



来源:https://stackoverflow.com/questions/56479576/i-got-the-expected-script1005-with-javascript-on-edge-with-chrome-its-wor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!