/dist/handsontable.full.js 404找不到凉亭

时间:2015-10-29 09:08:10

标签: express bower handsontable

我已经使用bower在its documentation上显示了Handsontable:

  

bower install handsontable --save

我将这些链接添加到view.ejs

<script src="/dist/handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="/dist/handsontable.full.css">

但我在浏览器中遇到了以下404错误

"NetworkError: 404 Not Found - http://localhost:3000/dist/handsontable.full.js"
handson...full.js

"NetworkError: 404 Not Found - http://localhost:3000/dist/handsontable.full.css"
handson...ull.css
ReferenceError: Handsontable is not defined in  

var hot = new Handsontable(container, {

即使我试图将链接更改为绝对文件位置(项目&#39; root作为参考):

<script src="./bower_components/handsontable/dist/handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="./bower_components/handsontable/dist/handsontable.full.css">

我仍然遇到同样的问题:

"NetworkError: 404 Not Found - http://localhost:3000/bower_components/handsontable/dist/handsontable.full.js"
handson...full.js
2
"NetworkError: 404 Not Found - http://localhost:3000/bower_components/handsontable/dist/handsontable.full.css"
handson...ull.css
ReferenceError: Handsontable is not defined


var hot = new Handsontable(container, {

---编辑----

这是我的项目结构,加载jquery.js也有同样的问题

enter image description here

我正在为this question尝试所有解决方案,但它们都没有效果。

1 个答案:

答案 0 :(得分:0)

这对我有用:

app.use("/bower_components", express.static(path.join(__dirname, 'bower_components'))); 

我的错误就是这样写:

app.use("bower_components", express.static(__dirname + '/bower_components')); // this is wrong

并且在视图中我写了什么并不重要

  

(./ bower_components或../ bower_components)。

所有这些对我有用:

<script src="../bower_components/handsontable/dist/handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="bower_components/handsontable/dist/handsontable.full.css">   
相关问题