Vue中Axios常用方法有哪些?

2024年06月12日 建站教程

get请求

import Axios from './config'

Axios.get('/user?id=1')
  .then(response => {})
  .catch(error => {})

post请求

import Axios from './config'

Axios.post('/user', {
    id: 1,
    name: 'user'
  })
  .then(response => {})
  .catch(error => {})

put请求

import Axios from './config'

Axios.put('/user', {
    id: 1,
    name: 'user'
  })
  .then(response => {})
  .catch(error => {})

delete请求

import Axios from './config'

Axios.delete('/user?id=1')
  .then(response => {})
  .catch(error => {})

PS:'./config'代码,请查看《Vue中如何实现Axios封装》

本文链接:http://so.lmcjl.com/news/6411/

展开阅读全文
相关内容