我试图以不同的方式返回,具体取决于查询参数,我如何在快递js中执行此操作
例如:
let circleView = UIView()
circleView.layer.cornerRadius = 10 // half of the width/height dimension
circleView.translatesAutoresizingMaskIntoConstraints = false
stepView.addSubview(circleView)
circleView.centerYAnchor.constraint(equalTo: stepLine.centerYAnchor).isActive = true
circleView.trailingAnchor.constraint(equalTo: stepLine.trailingAnchor).isActive = true
circleView.widthAnchor.constraint(equalToConstant: 20).isActive = true
circleView.heightAnchor.constraint(equalToConstant: 20).isActive = true
如果p = 1,它应该发送'hello',如果p不是1,它应该发送错误的
由于
答案 0 :(得分:1)
似乎你想使用路由参数。如果是这样的话,你就可以达到你想要的目的:
app.get('/:p', (req, res) => {
if (parseInt(req.params.p) == 1) {
res.send('hello');
}
else {
res.send('wrong')
};
});
答案 1 :(得分:0)
查询参数的示例 - > app.get('/:p', (req, res)=>{
,因为现在只要有p
端点运行此控制器或(req, res)=>{ handle the route here }
,所有人都会说。
Expressjs参数文档:http://expressjs.com/en/api.html#req.params