鍍金池/ 問答/HTML5  HTML/ node創(chuàng)建的本地服務(wù)器接收不到頁面?zhèn)鬟^來的值

node創(chuàng)建的本地服務(wù)器接收不到頁面?zhèn)鬟^來的值

小白一枚~
一個(gè)登陸注冊頁面,用vue寫的,登陸按鈕綁定的是login事件

    login () {
      var that = this;
      //$qs.stringify傳參轉(zhuǎn)換格式
      if(this.name != ''&& this.password !=''){
        this.$ajax.post('http://localhost:8081/login',this.$qs.stringify({   
          name: that.name,
          password: that.password,
        })).then(res=>{
          console.log(res.data.code);  //這個(gè)沒有打印出來
          if(res.data.code == 1){
            that.$message.success("驗(yàn)證通過");
            setTimeout(function(){
              that.$router.push("/mainnav")
            },500)
          } else{
            that.$message.error("賬號(hào)密碼錯(cuò)誤!")
          }
        })
      } else{
        this.$message.error("賬號(hào)密碼不能為空")
      }
    }
  }

后端代碼

    //登陸
    app.post('/login',function(req, res){
    console.log('select name from student where student = "' + req.body.name + '"and password = "' + req.body.password + '"'); //這里也沒有打印
    sql.query('select name from student where student = "' + req.body.name + '"and password = "' + req.body.password + '"', function (err, row) {
        if(err || row.length == 0) {
            console.log(err);
            res.send({code : 0});
        } else {
            res.send({code : 1});
        }
    });
});

控制臺(tái)沒有輸出,就是感覺值都沒有傳過來,求各位大佬解答~
還有bodyParser.urlencoded 中設(shè)置extended為true和為false我查了一下說
This object will contain key-value pairs, where the value can be a string or array (when extended is false), or any type (when extended is true).
那是不是意味著我使用true比false要好?在我沒有需要特定的類型的下。

回答
編輯回答
執(zhí)念

http://localhost:8081/login 改成 http://localhost:3000/login

后臺(tái)端口是3000

2018年2月7日 20:54