第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

axios在vue中的使用

難度中級
時長 3小時43分
學習人數(shù)
綜合評分9.43
58人評價 查看評價
9.3 內(nèi)容實用
9.3 簡潔易懂
9.7 邏輯清晰
  • //axios 實例

    let instead=axios.create({

    baseurl:Xxx,

    timeout:1000

    })

    instead.get('/data.json').then(res=>{

    console.log(res)

    })

    查看全部
  • //并發(fā)請求:同時請求多個接口數(shù)據(jù)

    //axios.all--同時請求多個axios.spread ---請求后統(tǒng)一處理返回值 分割處理

    axios.all([

    axios.get('/data.json'),

    axios.get('/city.json')

    ]).then(

    axios.spread((data res,cityres)=>{

    console.log(data res,cityres)

    })

    查看全部
    0 采集 收起 來源:并發(fā)請求

    2021-12-14

  • get 獲取數(shù)據(jù)

    post 提交數(shù)據(jù) 整個提交 如圖片 表單

    put 更新數(shù)據(jù) 全部數(shù)據(jù)提交

    patch 更新數(shù)據(jù) 更新修改的數(shù)據(jù)

    delete 刪除數(shù)據(jù)

    //post put patch 可使用formData

    let formData =new form Data()

    //一種方式

    axios.delete('/json',{

    params :{

    id:12//接口請求會帶參數(shù)

    }

    }).then(res=>{

    console.log(res)

    })

    //另一種方式

    axios({

    method:'delete',

    url:'/json',

    params:{},

    data:{}

    }).then(res=>{

    console.log(res)

    })

    查看全部
  • axios 實例

    查看全部
  • axios post請求

    查看全部
  • axios post請求

    查看全部
  • axios get請求

    查看全部
  • axios get請求

    查看全部
  • post form-data請求


    619355c50001cb5106400360.jpg
    查看全部
  • post請求

    用?applicition/json格式攜帶數(shù)據(jù)

    ??http://img1.sycdn.imooc.com//6179f4730001f79507260387.jpg

    用form-data格式? (常用來表單提交 圖片上傳,文件上傳)

    http://img1.sycdn.imooc.com//6179f87b0001b33506120339.jpg

    put和patch請求,是和post的請求方式是一樣的,請求數(shù)據(jù)格式也是兩種

    delete請求

    參數(shù)只有兩個

    http://img1.sycdn.imooc.com//6179fcb40001dc3505320216.jpg

    并發(fā)請求

    axios.all()中接收一個數(shù)組,數(shù)組中可以發(fā)送多個請求,axios.spread()中是回調(diào)函數(shù),用來接收返回值

    http://img1.sycdn.imooc.com//617a026400018d3605900269.jpg

    創(chuàng)建axios實例

    當我們請求的端口號不同,超時時間不同,可以創(chuàng)建axios實例,為其單獨配置相關(guān)數(shù)據(jù)

    http://img1.sycdn.imooc.com//617a06260001e00405760248.jpg

    攔截器

    在請求或響應(yīng)被處理前攔截

    請求攔截器

    http://img1.sycdn.imooc.com//617a1ccb00011d5307820366.jpg

    響應(yīng)攔截器

    http://img1.sycdn.imooc.com//617a1d4c0001676606850328.jpg

    查看全部
  • ---axios---

    npm install axios 安裝

    import axios from ‘a(chǎn)xios’?引入

    請求的五種方式

    Get:請求數(shù)據(jù)

    Post:提交數(shù)據(jù)(表單提交)

    Put:更新數(shù)據(jù)(所有數(shù)據(jù)推送給后端)

    Patch:更新數(shù)據(jù)(將更改的數(shù)據(jù)推送給后端)

    Delete:刪除數(shù)據(jù)

    http://img1.sycdn.imooc.com//61795aeb0001c21d02930345.jpg


    查看全部
  • 封裝請求
    async 方法
    查看全部
  • 并發(fā):?

    axios.all([

    ????{url:"",methed:""},

    ????{url:"",methed:""},

    ]).then(axios.par...)

    查看全部
  • axios錯誤處理 :請求錯誤時進行的處理

    axios.interceptors.request.use(config=>{
    ????return?config
    },err=>{
    ????return?Promise.reject(err)?
    })

    axios.interceptors.response.use(res=>{
    ????return?res
    },err=>{
    ????return?Promise.reject(err)??
    })

    //無論是請求錯誤還是響應(yīng)錯誤都會進到catch里
    axios.get('/data.json').then(res=>{
    }).catch(err=>{
    ????console.log(err)
    })

    //例子,實際開發(fā)中?一般添加統(tǒng)一的錯誤處理
    let?instance?=?axios.create({})
    instance.interceptors.request.use(config=>{
    ????return?config
    },err=>{
    ????//請求錯誤?一般http狀態(tài)碼開頭,常見?401超時?404?not?fonud
    ????$('#modal').show()
    ????setTimeout(()=>{
    ????????$('#modal').hide()
    ????},2000)
    ????return?Promise.reject(err)??
    })
    instance.interceptors.response.use(res=>{
    ????return?res
    },err=>{
    ????//響應(yīng)錯誤處理?一般http開頭的狀態(tài)碼以5開頭,?500系統(tǒng)錯誤??502系統(tǒng)重啟
    ????$('#modal').show()
    ????setTimeout(()=>{
    ????????$('#modal').hide()
    ????},2000)
    ????return?Promise.reject(err)??
    })

    //如果是不需要做特殊的錯誤處理就不需要寫.catch
    instance.get('/data.json').then(res=>{
    ????console.log(res)???//
    }).catch(err=>{})

    查看全部
    0 采集 收起 來源:錯誤處理

    2021-06-27

  • 下載老師用node寫的后臺接口項目,然后啟用Powershell窗口安裝依賴,然后輸入node index.js命令運行,啟用接口服務(wù)

    查看全部

舉報

0/150
提交
取消
課程須知
1.對vue有一定的了解 2.對ES6有一定的了解 3.對數(shù)據(jù)請求有一定的了解(如ajax)
老師告訴你能學到什么?
1. axios的基本用法; 2. axios的各種請求方法以及相關(guān)配置; 3. axios的攔截器,合并請求,取消請求; 4. 如何在項目中優(yōu)雅的使用Axios。

微信掃碼,參與3人拼團

微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網(wǎng)的支持!