.
This commit is contained in:
14
Web/public/doc-code/api/setting.js
Normal file
14
Web/public/doc-code/api/setting.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export default {
|
||||
/* 自定义的接口名称 */
|
||||
apiName: [
|
||||
/* 接口地址 */
|
||||
url,
|
||||
/* 请求类型 [get | post] */
|
||||
'get',
|
||||
/* axios所需的设置参数 */
|
||||
options,
|
||||
],
|
||||
|
||||
/* 默认为get接口 */
|
||||
apiPostName: getUrl
|
||||
}
|
||||
25
Web/public/doc-code/api/usage.js
Normal file
25
Web/public/doc-code/api/usage.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { api } from 'common/api'
|
||||
|
||||
api.apiName(params)
|
||||
.then(res => {
|
||||
/* ... */
|
||||
})
|
||||
.catch(error => {
|
||||
/* catch */
|
||||
})
|
||||
.finally(() => {
|
||||
/* finally */
|
||||
})
|
||||
|
||||
|
||||
// 或者采用异步
|
||||
async function foo() {
|
||||
try {
|
||||
const res = await api.apiName(params)
|
||||
/* ... */
|
||||
} catch (error) {
|
||||
/* catch */
|
||||
} finally {
|
||||
/* finally */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user