2017-03-07 67 views
0

在我的项目试图引用CSS时,我收到以下错误加载从bower_components资源和JS文件无法使用Vue.js CLI

Failed to load resource: the server responded with a status of 404 (Not Found) 
http://localhost:8080/bower_components/bootstrap/dist/css/bootstrap.min.css 

这是我的文件结构

app 
    |bower_components 
     |bootstrap 
      |dist 
       |css 
        | bootstrap.min.css 
     |jquery 
      |dist 
       |jquery.min.js 
    |build 
    |config 
    |node_modules 
    |src 
    |static 
    |index.html //The file I am receiving error on 
public //using Slim framework with PHP to generate RESTful API 
src 
vendor 

在我的index.html文件我正在使用以下代码尝试引用bootstrap.min.css文件

<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="utf-8"> 
    <title>Template</title> 
    <link rel="stylesheet" href="./bower_components/bootstrap/dist/css/bootstrap.min.css"> 
    </head> 
    <body> 
    <div id="app"></div> 
    </body> 
</html> 

我正在使用Visual Studio代码,这使得能够CTRL +单击链接到bootstrap.min.css文件并加载好,所以我不确定我在哪里出错了?

我使用vue.js CLI作为app文件夹,并使用与Slim FrameworkPHP产生如果那帮助public/src/vendor文件夹一个RESTful API?任何帮助将不胜感激。

+0

你试过从链接“./”删除? – Aaron

+0

@Aaron是的,仍然收到相同的错误。我已经尝试过使用vue.js CLI,它的工作原理,所以它肯定与此有关,只是不知道如何... – mcclosa

回答

0

我能够解决这个问题,它与使用Vue.js CLI链接。

我需要添加的文件夹bower_components为静态文件夹,然后引用该文件就像

<link rel="stylesheet" href="./static/bower_components/bootstrap/dist/css/bootstrap.min.css">