路由 uview升级 api
This commit is contained in:
17
common/http.api.js
Normal file
17
common/http.api.js
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
// 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作,更多内容详见uView对拦截器的介绍部分:
|
||||
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
|
||||
const install = (Vue, vm) => {
|
||||
// 此处没有使用传入的params参数
|
||||
let api = {
|
||||
getLiveSpec(){
|
||||
return vm.$u.get("Streaming/getLiveSpec")
|
||||
}
|
||||
}
|
||||
// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
|
||||
vm.$u.api = api;
|
||||
}
|
||||
|
||||
export default {
|
||||
install
|
||||
}
|
||||
17
common/http.interceptor.js
Normal file
17
common/http.interceptor.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const install = (Vue, vm) => {
|
||||
// 此为自定义配置参数,具体参数见上方说明
|
||||
Vue.prototype.$u.http.setConfig({
|
||||
baseUrl: 'https://dmmall.sdbairui.com//storeapi/',
|
||||
loadingText: '努力加载中~',
|
||||
loadingTime: 800,
|
||||
// 设置自定义头部content-type
|
||||
// header: {
|
||||
// 'content-type': 'xxx'
|
||||
// }
|
||||
// ......
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
install
|
||||
}
|
||||
Reference in New Issue
Block a user