这是我的快速设置:
var express = require('express')
var app = express()
app.use(express.static('public'))
app.get('*', function (req, res) {
res.sendfile('dist/index.html')
})
app.listen(process.env.PORT || 3000, function () {
console.log('Example app listening on port 3000!')
})
这是dist
:
这是index.html
:
<!DOCTYPE html><html><head><meta charset=utf-8><title>iStaging LiveTour</title><link href=/static/css/app.b96fc026269e85d4507be6f2804573f0.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.e3bed1667f2313b8b537.js></script><script type=text/javascript src=/static/js/vendor.9a48bc75d44e45d7cd37.js></script><script type=text/javascript src=/static/js/app.c3f229f9ac04906ac631.js></script></body></html>
我收到此错误:
Uncaught SyntaxError: Unexpected token <
可能是什么原因?
答案 0 :(得分:-1)
看起来你有很多可以自动关闭的标签,这会降低尖括号的数量,从而导致出现问题。另外我注意到你的css引用看起来很奇怪,你的Javascript引用在体内(无所谓但我把它们放在头部)。试试吧。
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>iStaging LiveTour</title>
<link rel="stylesheet" type="text/css" href="/static/css/app.b96fc026269e85d4507be6f2804573f0.css">.
<script type=text/javascript src=/static/js/manifest.e3bed1667f2313b8b537.js />
<script type=text/javascript src=/static/js/vendor.9a48bc75d44e45d7cd37.js />
<script type=text/javascript src=/static/js/app.c3f229f9ac04906ac631.js />
</head>
<body>
<div id=app />
</body>
</html>