I would like to know why my website is not showing up on Edge? it's developed on JavaScript

假装没事ソ 提交于 2019-12-24 09:59:50

问题


Thing is someone told me that this "..." is not supported on Edge. There's something with the following code that has compatibility problems and the website is not showing up.

Here's the code:

    //<< Mapping  hash
    hash = {
        route: hash[0].split(/\//)[0],
        params: hash[0].split(/\//).slice(1),
        queryParams: hash.length > 1 ? hash[1] : "",
    }

    hash.queryParams = hash.queryParams?hash.queryParams.split(/&/).reduce((a, c, i) => {
        return {...a,...{[c.split(/=/)[0]]: c.split(/=/)[1]}}
    }, {}):{}; // I got to fix this (Reynald - 12: 35 pm)
    //>>

The problem is specially on the hash.queryParams = ....

I'm going to split the complete function with its property and every method used on it. I know I will get a larger way so Edge doesn't get any problem on reading the website.

hash.queryParams = hash.queryParams?hash.queryParams.split(/&/).reduce((a, c, i) => {
        return {...a,...{[c.split(/=/)[0]]: c.split(/=/)[1]}}
    }, {}):{}; // I got to fix this (Reynald - 12: 35 pm)```

Anything by the moment. The output is that the website should be rendered from an external file which has a JavaScript that is drawing the website on an index.html, what I mean is for example a main.js that is drawing at index.html and the main.js has connections to call every independent page with each corresponding file.


回答1:


Seems that spread operators are not supported in Edge for destructuring, so whoever told you that was correct. Unless you want to deal with transpiling your code, you can try using Object.assign().

Replace return {...a,...{[c.split(/=/)[0]]: c.split(/=/)[1]}} with something like:

return Object.assign(a, {[c.split(/=/)[0]]: c.split(/=/)[1]})


来源:https://stackoverflow.com/questions/56466115/i-would-like-to-know-why-my-website-is-not-showing-up-on-edge-its-developed-on

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