首页 > 解决方案 > 教程中的完全相同的代码不断给我语法错误

问题描述

所以...这是来自 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) {


    });

}

标签: javascriptnode.js

解决方案


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


    });

}

推荐阅读