使用fly post请求传递参数不成功问题解决

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35746765/article/details/82380990

使用qs库来格式化数据
npm install qs --save 

在main.js中,我们引入qs库
// post请求是格式化数据
import qs from 'qs';
Vue.prototype.$qs = qs;

进行post请求
    this.$axios
        .post(
          "/app/user/login.do",
          this.$qs.stringify({
            username: this.name,
            password: MD5(this.pwd)
          })
        )
        .then(response => {
          console.log(response.data);
        })
        .catch(error => {
          console.log(error);
          this.$toast("网络错误,不能访问");
        });

到这里就可以请求成功了!
 

猜你喜欢

转载自blog.csdn.net/qq_35746765/article/details/82380990