TypeError:res不是函数

时间:2019-10-15 04:38:45

标签: javascript html mysql node.js express

let segmentedControl: UISegmentedControl = {
    let sc = UISegmentedControl(items: ["Inventory", "Sale", "Expense"])
    sc.selectedSegmentIndex = 0
    sc.layer.cornerRadius = 9
    sc.layer.borderWidth = 1
    sc.layer.borderColor = UIColor.lightGray.cgColor
    sc.layer.masksToBounds = true
    sc.frame = CGRect(origin: CGPoint(x: 10, y: 280), size: CGSize(width: 300, height: 30))

    sc.addTarget(self, action: #selector(handleSegmentChange), for: .valueChanged)
    return sc
}()

2 个答案:

答案 0 :(得分:1)

res是对象响应,它包含您在完成响应后将关闭的大量工具和数据。

检查节点API doc

res()替换为res.end()

或渲染:

exports.signup_submit = function(req,res){ 
  console.log(req.body.username,"------------------"); 
  var sql = "INSERT INTO customers (username) VALUES (req.body.username)"; 
  con.query(sql, function (err, result, fields) { 
       if (err) { 
         return res.render(__dirname + '/views/error.html'); 
        }

       res.render(__dirname + '/views/success.html');    
    });

答案 1 :(得分:0)

您需要使用“ res.send”或“ res.render” 如果您在模板上的错误中有特殊的位置,则可以使用“ res.render(path_to_template,error)”

您可以详细了解here