【Vue】axios的使用

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

axios的安装和使用

安装:npm install axios

1.在main.js中引入axios

import axios from 'axios'
import qs from 'qs'

Vue.prototype.$axios = axios    //全局注册,使用方法为:this.$axios
Vue.prototype.qs = qs           //全局注册,使用方法为:this.qs

2.使用请求

  methods:{
    handleSubmit () {
      this.$axios.post('http://192.168.22.238:8008/OrderSystem/User/isExist',{
        userId:this.CardNo,
        password:this.password,
    }).then((response)=>{
      console.log(response.data) 
    }).catch((error)=> {
      console.log(error);
    });
    }
  }

3.效果图
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/TheBestAge/article/details/89301096
今日推荐