#author("2022-08-18T10:20:22+08:00","default:Admin","Admin")
#author("2023-10-24T14:14:11+08:00","default:Admin","Admin")
[[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

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS