我是React學習的新手。我剛剛從這個網站上下載了Starter Kit 15.3.0:https://facebook.github.io/react/docs/getting-started.html在chrome中加載react.js的錯誤
我正在使用chrome瀏覽器。當試圖包括單獨的js文件轉換成HTML頁面一樣
https://facebook.github.io/react/docs/getting-started.html#separate-file
說,鉻報告錯誤:
XMLHttpRequest cannot load file:///C:/Users/jxu200/Desktop/react-15.3.0/src/helloworld.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
我注意到,它是由提到反應團隊:
Note that some browsers (Chrome, e.g.) will fail to load the file unless it's served
via HTTP.
我的問題是:爲什麼
react.js/react-dom.js/react-dom-server.js/react-with-addons.js,
所有js文件在/ build文件夾中c一個沒有問題的加載,但由我自己創建的js文件不能正常加載?即使我把我的js文件放在/ build文件夾中?加載react.js代碼時,chrome實際上會做什麼?
W沒有看到你如何加載該文件,這是不可能回答這個問題。 – zerkms
作爲腳本標籤加載的文件不容易受到相同的源策略影響(請閱讀它的內容)。您應該使用靜態HTTP開發服務器 –