[英]Page working with `grunt serve` but not when I load index.html
GitHub 存儲庫: https : //github.com/grahamlutz/MyVirtualPack
當我使用 grunt serve 來啟動一個監聽localhost:9000
的服務器時,頁面看起來並且工作正常。 當我嘗試在瀏覽器中加載 index.html 時,我無法訪問 bower_components 文件夾,該文件夾是目錄中 index.html 上方的文件夾。
GET file:///bower_components/modernizr/modernizr.js net::ERR_FILE_NOT_FOUND
index.html:190 GET file:///bower_components/jquery/dist/jquery.js net::ERR_FILE_NOT_FOUND - index.html:195
GET file:///bower_components/bootstrap-sass/assets/javascripts/bootstrap/affix.js net::ERR_FILE_NOT_FOUND - index.html:196
GET file:///bower_components/bootstrap-sass/assets/javascripts/bootstrap/alert.js net::ERR_FILE_NOT_FOUND - index.html:196
...等等。
我不確定要問什么,希望我不知道在使用 grunt serve 時會發生什么不同?
實際上,您的問題是由絕對路徑引起的:它們在第 191 行及更多行以 '/' 開頭。 它們在http:
request(grunt serve 或您的 GoDaddy)的上下文中工作正常,但不適用於簡單的file:
request(這是您在瀏覽器中加載本地文件時得到的)。
用相對路徑( ../bower_components/[...]
)替換它們,你應該很好 - 這可能需要對你的有線配置進行一些工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.