Javascript module not working in browser?

前端 未结 8 1886
半阙折子戏
半阙折子戏 2020-12-10 11:35

Alright, I have looked on this site and have found several different answers, none of which have worked for me. Basically had a js file that had many functions in it along

8条回答
  •  天涯浪人
    2020-12-10 12:16

    Consider going through this url some extension might be causing an issue with the loading of modules:

    This blog might be an answer to what you're expecting.

    You should first check if browser accepts type="module" and use fallback if it doesn't like this:

    
    
    

    This might be the main reason for the CORS error as written here:

    Unlike regular scripts, module scripts (and their imports) are fetched with CORS. This means cross-origin module scripts must return valid CORS headers such as Access-Control-Allow-Origin: *

    So you need to add CORS header to the module file

    Consider this blog for CORS issue. You should add CORS header ie. Access-Control-Allow-Origin: * to the server config most probably.

提交回复
热议问题