【求助】express post找不到
发布于 8 年前 作者 MakisuCruse 3221 次浏览 来自 问答

express 版本是4.14.0 找不到app.post()这个方法。。做过的朋友帮帮忙啊 代码如下: var express=require(‘express’); var app=express(); //var app=express(); app.get(’/’,function (req,res) { res.render(‘index’,{title:‘Express’}); }); app.post() module.exports=app;

3 回复

app.post 后面要跟路由啊

app.post('/', function(){});

这样

恩,我这里没有写完整。。照那个写了后显示function not found …

显示这个: app.post is not a function

TypeError: app.post is not a function at module.exports (/Users/makisucruse/WebstormProjects/test/routes/index.js:18:9) at Layer.handle [as handle_request] (/Users/makisucruse/WebstormProjects/test/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/makisucruse/WebstormProjects/test/node_modules/express/lib/router/index.js:312:13) at /Users/makisucruse/WebstormProjects/test/node_modules/express/lib/router/index.js:280:7 at Function.process_params (/Users/makisucruse/WebstormProjects/test/node_modules/express/lib/router/index.js:330:12) at next (/Users/makisucruse/WebstormProjects/test/node_modules/express/lib/router/index.js:271:10) at SendStream.error (/Users/makisucruse/WebstormProjects/test/node_modules/serve-static/index.js:121:7) at emitOne (events.js:77:13) at SendStream.emit (events.js:169:7) at SendStream.error (/Users/makisucruse/WebstormProjects/test/node_modules/send/index.js:275:17) at SendStream.onStatError (/Users/makisucruse/WebstormProjects/test/node_modules/send/index.js:392:12) at next (/Users/makisucruse/WebstormProjects/test/node_modules/send/index.js:711:28) at /Users/makisucruse/WebstormProjects/test/node_modules/send/index.js:719:23 at FSReqWrap.oncomplete (fs.js:82:15)

回到顶部