Vueのインタフェース呼び出しはvue-resourcesですか、axiosですか.
vue-resources公式はもうお勧めしませんが、
インストール
使用方法(RESTful)
GETリクエスト
POSTリクエスト
PUT要求
「同期」するのは簡単です
axios
を使いましょう.インストール
npm install axios --save
使用方法(RESTful)
GETリクエスト
Axios.get('article', {
params: {id: 10010}
}).then(res => {
console.log(res)
}).catch(err => {
console.log(err)
})
POSTリクエスト
Axios.post('article', {
title: 'Axios is very N13',
content: 'Yes, I can not agree with you more.'
}).then(res => {
console.log(res)
}).catch(err => {
console.log(err)
})
PUT要求
Axios.put('article', {
id: 10010,
title: 'Axios is very N13',
content: 'Yes, I can not agree with you more.'
}).then(res => {
console.log(res)
}).catch(err => {
console.log(err)
})
「同期」するのは簡単です
axios
はPromise実装です.これは、await
キーワードを使用して同期呼び出しを実装できることを意味します.