二次封装uni-app的uni.request 网络请求接口
- 安装
npm install uni-app-http
- 在main.js中引用
import http from 'uni-app-http'
http.setHost('you host')
Vue.prototype.$http = http
- 运用
async onLoad() {
const end = this.$http.getHost()
this.$http.get('/xxx').then((e) => {console.log(e, 22)})
const data = await this.$http.get('/xxx')
}
- url
- data
- contentType
- url
- data
- url