【发布时间】:2021-04-01 14:21:40
【问题描述】:
我有一个错误,这里是代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button class="get" function="getInfo">Get Information</button>
<script src="../server/app.js"></script>
<script>
function getInfo() {
request('http://www.google.com', function (error, response, body) {
console.log('Status: ' + response && response.statusCode)
console.log('Body: ' + body)
})
}
</script>
</body>
</html>
而且报错很奇怪,看:
<!DOCTYPE html>
^
SyntaxError: Unexpected token '<'
提前感谢所有建议! P.S 抱歉英语不好!
【问题讨论】:
-
此代码
<!DOCTYPE html>在您的文件中的什么位置?你保存的文件扩展名是什么? -
对不起,堆栈溢出不包括第一行,我的文件有.html扩展名
-
某些东西正试图将 HTML 解析为非 HTML(很可能是 JS 或 JSON),但没有足够的上下文来说明什么。
-
该错误何时何地出现?
-
鉴于它被标记为node.js,甚至金钱都说它会变成stackoverflow.com/questions/57572302/…的另一个副本
标签: html node.js syntax-error