Vue使用axios post方法發送json數據報415Unsupported Media Type


1.Vue使用axios post方法發送json數據

<template>
  <el-aside>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="審核選擇">
        <el-switch
            v-model="form.status"
            active-text="審核通過"
            active-value="2"
            inactive-text="審核不通過"
            inactive-value="3"
            active-color="#13ce66"
            inactive-color="#ff4949">
        </el-switch>
      </el-form-item>

      <el-form-item label="處理原因">
        <el-input type="textarea" v-model="form.reason"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
        <el-button @click="cancel">取消</el-button>
      </el-form-item>
    </el-form>

  </el-aside>
</template>

<script>
import axios from "axios";

export default {
  name: "StoreHandler",
  data() {
    return {
      form: {
        status: '2',
        reason: ''
      }
    }
  },

  methods: {
    onSubmit() {
      console.log(this)
      console.log(this.form.status)
      console.log(this.form.reason)
      console.log(this.$route.query.storeId)

      const jsons = {
        storeId:this.$route.query.storeId,
        status: this.form.status,
        reason: this.form.reason
      };

      let _this = this

      axios({
        method: 'post',
        url: 'http://localhost:1111/waimai/store/updateStoreStatusAndReason',
        data: JSON.stringify(jsons),
        headers: {
          'Content-Type': 'application/json;charset=UTF-8'
        }
      }).then(function (res) {
        console.log(res)
        _this.$notify({
          title: '提交成功',
          message: '處理結果',
          type: 'success'
        })

        _this.$router.push({
          path:'/storeApplyList'
        })
      })
    },

    cancel() {
      this.$router.push({
        path: '/storeAppLyList'
      })
    }
  },
}
</script>

<style scoped>

</style>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM