node.js - express的路由打印
PHP中文网
PHP中文网 2017-04-17 16:31:35
0
1
296

比如下面这个是我的web服务启动项
我想打印下app.get里的req.params方法,不过好像打印不出来,
要怎么看???

var path = require('path');
var fs = require('fs');
var express = require('express');
var webpack = require('webpack');
var http = require('http');
var compression = require('compression');
var consolidate = require('consolidate');
var webpackConfig = require('./webpack.dev.conf');

//端口
var port = process.env.PORT || 8080;
var app = express();
app.engine('html', consolidate.ejs);
app.set('views', 'view');
app.set('view engine','html');

app.use(compression()); //开启 gzip

//webpack编译器
var compiler = webpack(webpackConfig);
//webpack-dev-server 中间件
var devMiddleware = require('webpack-dev-middleware')(compiler, {
    publicPath: webpackConfig.output.publicPath,
    stats: {
        colors: true,
        chunks: false
    }
});

//热更新中间件
var hotMiddleware = require('webpack-hot-middleware')(compiler);

app.use(devMiddleware);
app.use(hotMiddleware);

// 路由
app.get('/', function(req, res, next) {
    console.log(req.params)
});

//静态资源目录
app.use('/resources', express.static(__dirname + '/resources'));

app.listen(port, function(){
    console.log("node启动 监听端口:" + port);
});
PHP中文网
PHP中文网

认证高级PHP讲师

全部回复(1)
Ty80

你的路由监听是不是以下方式?

如果不是,可以用req.query获取请求参数。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板