vue-axios增加操作

<template>
  <div class="Insert">
    <label for="name">名称:</label><input v-model="name" type="text" />
    <label for="location">部门:</label><input v-model="location" type="text" />
    <br />
    <input value="增加" @click="Insert()" type="button" />
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "LoginView",
  data() {
    return {
      name: "",
      location: "",
    };
  },
  methods: {
    Insert() {
      axios({
        // 请求方式/
        method: "POST",

        // 请求地址
        url: "http://localhost:8086/Insert",

        data: {
          name: this.name,
          location: this.location,
        },
      })
    },
  },
};
</script>

 

posted @ 2022-10-31 14:25  しゅおく  阅读(36)  评论(0)    收藏  举报