【发布时间】:2015-09-23 15:22:07
【问题描述】:
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 时会发生什么不同?
【问题讨论】:
-
当您使用
grunt serve或任何其他服务器时,它将使用服务器的相对路径并且可以正常工作。当你在没有服务器的情况下运行 index.html 时,文件路径不正确,所以它不起作用。 -
谢谢@Tushar。那么有没有办法在运行 index.html 时使用相对路径?另外,如果/当我用 goDaddy 之类的东西托管它时,它会使用相对路径吗?
标签: javascript jquery angularjs twitter-bootstrap gruntjs