from origin ‘null‘ has been blocked by CORS policy: Cross origin requests are only supported for pro


 

參考文章

visual studio code 中使用 open in browser 插件,在瀏覽器中打開 html 文件后,如下圖所示:

 

從Sources選項卡中可以看出來,並沒有加載 javascript 文件,如下圖所示:

 

每個人開發自己的模塊

報錯內容為:
Access to script at 'file:///D:/My%20Study/Vue/learn-vuejs/LearnVuejs04/12-%E5%89%8D%E7%AB%AF%E6%A8%A1%E5%9D%97%E5%8C%96/02-ES6%E7%9A%84%E6%A8%A1%E5%9D%97%E5%8C%96%E5%AE%9E%E7%8E%B0/xiaoming.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https, chrome-untrusted.

解決辦法:
我這里安裝了 node.js 環境,使用 npm 安裝 anywhere ,npm install anywhere -g 如下圖:

 

 


切換到需要運行的 html 文件的目錄,在 cmd 中運行 anywhere,如下:

 

 

運行 anywhere 后發現,js 文件全部加載進來了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM