Axios
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[Vue]]
&color(red){※前提条件:本文基于 Vue 2.0 创作};
#contents
* create [#j684b01c]
axios.create()是添加了自定义配置的新的axios
#codeprettify{{
axios({
method:'POST',
url:'http://localhost:8080/login',
data
})
}}
优点
+ 可以简化路径写法
+ 当基础路径发生变化时方便修改,有利于维护
#codeprettify{{
cosnt instance = axios.create({
baseURL:'http://localhost:8081/' //路径
})
instance({
url: '/login',
method: 'POST',
data: resData
})
}}
* POST和GET [#r779685c]
- POST时用data。参数会被post出去
- GET时用params。参数会拼接在url
#codeprettify{{
return request({
url: '/User/Login',
method: 'get',
params/data: {
username,
password,
},
});
}}
#hr();
コメント:
#comment_kcaptcha
終了行:
[[Vue]]
&color(red){※前提条件:本文基于 Vue 2.0 创作};
#contents
* create [#j684b01c]
axios.create()是添加了自定义配置的新的axios
#codeprettify{{
axios({
method:'POST',
url:'http://localhost:8080/login',
data
})
}}
优点
+ 可以简化路径写法
+ 当基础路径发生变化时方便修改,有利于维护
#codeprettify{{
cosnt instance = axios.create({
baseURL:'http://localhost:8081/' //路径
})
instance({
url: '/login',
method: 'POST',
data: resData
})
}}
* POST和GET [#r779685c]
- POST时用data。参数会被post出去
- GET时用params。参数会拼接在url
#codeprettify{{
return request({
url: '/User/Login',
method: 'get',
params/data: {
username,
password,
},
});
}}
#hr();
コメント:
#comment_kcaptcha
ページ名: