Introduce and use axios

Install axios

Please ignore this one already installed

npm install axios - save

Introduce axios in mian.js or index.js

import 'element-ui/lib/theme-chalk/index.css'
//Element
import axios from 'axios'
Vue.prototype.$http = axios

Introduce axios in the components that need to be used

import $http from 'axios'

use

mounted(){
    
    
    window.console.log($http)
    this.$http
            .get('http://jsonplaceholder.typicode.com/users')
            .then((res)=>{
    
    
              console.log(res)
            })
  }

Guess you like

Origin blog.csdn.net/qq_44977477/article/details/103073835