问题描述

问题解决方案

 

headers: {
              "Content-Type": "application/x-www-form-urlencoded"
         }

添加上述?代码即可! 

!!! 还有个重点问题,关于提交表单,要使用qs

1. 添加qs 插件 npm install qs --save-dev

2. 使用

3. 代码 

<script>
import qs from "qs";
export default {
  data() {
    return {
      form: {
        scheduleName: "",
        scheduleAddr: "",
        scheduleTime: ""
      }
    };
  },
  methods: {
    backScheduleList() {
      this.$router.replace({
        path: "/schedule-list"
      });
    },
    onSubmit() {
      let params = {
        scheduleName: this.form.scheduleName,
        scheduleAddr: this.form.scheduleAddr,
        scheduleTime: this.form.scheduleTime
      };
      params = qs.stringify(params);
      this.$axios
        .post("http://domla.xyz:8080/member/schedule", params, {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded"
          }
        })
        .then(response => {
          if (response.data.code == 200) {
            this.$message({
              type: "success",
              message: "添加成功!"
            });
          } else {
            this.$message({
              type: "error",
              message: "添加失败!"
            });
          }
        });
    }
  }
};
</script>

 

Logo

前往低代码交流专区

更多推荐