javascript - 教程中的完全相同的代码不断给我语法错误
问题描述
所以...这是来自 youtube 教程的完全相同的代码,当他输入此代码并运行它时,他没有收到一个错误,但是当我这样做时,我收到了 2 个错误,即“;” 预期和“,”预期。教程原代码链接:https ://youtu.be/IgAH0NqsJso?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp&t=58
module.exports = funciton(app) {
app.get('/todo', function(req, res) {
res.render('todo');
});
app.post('/todo', funciton(req, res) {
});
app.delete('/todo:item', function(req, res) {
});
}
解决方案
This is the correct one. Please watch the video more carefully. Also, follow the error messages. There is the line number in error message. Just check the line number and find what went wrong. :)
module.exports = function(app) { // misspelled the word 'function'
app.get('/todo', function(req, res) {
res.render('todo');
});
app.post('/todo', function(req, res) { // misspelled the word 'function'
});
app.delete('/todo/:item', function(req, res) { // Missed "/" in the end point
});
}
推荐阅读
- java - 如何在 Android Studio 中更改活动优先级
- python - 通过字典键链接嵌套列表中的对象
- angular - Ngx-datatable - ng-template 进度条问题
- visual-studio - 如何在 Visual Studio 2012 中更改 SQL 数据库名称
- c - 如何在c中的递归算法中通过引用传递参数?
- javascript - 从选择框中传递值作为 React 中的参数
- python - 如何在 Pyplot 中获得平滑的平均曲线
- git - grep 存储库中的所有提交
- swift - 更改 WKInterfaceLabel 文本
- java - 如何仅使用 KeyListener 旋转一次摆动的矩形,而无需再次旋转