zoukankan      html  css  js  c++  java
  • vue中参数传不到后台去怎么办?

    刚开始学习vue,遇到一个参数传不到后台去的问题~
    问题代码是这样的:
    checkin (){
    var phoneNumber=this.phone;
    var userpassword=this.yzm;
    this.$http.post('myurl',{
    mobilePhone:phoneNumber,
    password:userpassword
    }).then(function(res){
    this.$root.userid=res.data.userid;
    console.log(this.$root.userid)
    this.$router.push('/content') ;
    });
    }
     
    经过查询,添加了emulateJSON: true,就可以了,
    这行代码能将参数们以json格式传到后台,后台才能接收到。
    改好的代码如下:
    checkin (){
    var phoneNumber=this.phone;
    var userpassword=this.yzm;
    this.$http.post('my url',{
    mobilePhone:phoneNumber,
    password:userpassword
    },{
    emulateJSON: true
    }
    ).then(function(res){
    this.$root.userid=res.data.userid;
    console.log(this.$root.userid)
    this.$router.push('/content') ;
    });
    }
     
     
     
  • 相关阅读:
    BigDecimal 和NumberFormat及 获取总页数的应用
    格式化小数点和百分号 DecimalFormatter
    Vue 项目开发
    js 对象补充
    Vue 实例成员
    Vue 指令
    Vue 介绍
    Vue
    request-html
    Python 中的经典类新式类
  • 原文地址:https://www.cnblogs.com/ellenbaby/p/9006814.html
Copyright © 2011-2022 走看看