从网上下载的html本地运行,出错,按F12,发现:
Access to script at 'file:///F:/xxx/yyy.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
按网上解决方法,在chrome快捷方式“目标”:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-file-access-from-files
运行不出这个错了,又换了一个错误:
Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
还是没有解决,win10上正好有Ubuntu,进入html目录,运行:
python -m SimpleHTTPServer 8080
就启动一个服务器了,再在chrome里输入:
http://localhost:8080/
就可以选择打开需要的网页了,运行OK。