mirror of https://github.com/shunfei/cronsun
添加请求失败默认处理函数
parent
4f7a6625ee
commit
01b4ba5d6b
|
@ -158,7 +158,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).
|
}).
|
||||||
onfailed((data)=>{vm.error = data.error}).
|
onfailed((msg)=>{vm.error = msg}).
|
||||||
do();
|
do();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ var sendXHR = function(opt) {
|
||||||
xhr.open(opt.method, opt.url, true);
|
xhr.open(opt.method, opt.url, true);
|
||||||
|
|
||||||
if (typeof opt.onexception == 'function') {
|
if (typeof opt.onexception == 'function') {
|
||||||
var warpExceptionHandler = ()=>{
|
var warpExceptionHandler = (msg)=>{
|
||||||
opt.onexception(msg);
|
opt.onexception(msg);
|
||||||
typeof opt.onend == 'function' && opt.onend(xhr);
|
typeof opt.onend == 'function' && opt.onend(xhr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,9 @@ const RestApi = (Vue, options)=>{
|
||||||
Vue.use(RestApi);
|
Vue.use(RestApi);
|
||||||
|
|
||||||
// global event bus
|
// global event bus
|
||||||
|
var bus = new Vue();
|
||||||
Vue.use((Vue)=>{
|
Vue.use((Vue)=>{
|
||||||
Vue.prototype.$bus = new Vue();
|
Vue.prototype.$bus = bus;
|
||||||
});
|
});
|
||||||
|
|
||||||
import VueRouter from 'vue-router';
|
import VueRouter from 'vue-router';
|
||||||
|
@ -57,6 +58,9 @@ restApi.GET('configurations').onsucceed(200, (resp)=>{
|
||||||
}
|
}
|
||||||
Vue.use(Config);
|
Vue.use(Config);
|
||||||
|
|
||||||
|
restApi.defaultExceptionHandler = (msg)=>{bus.$emit('error', msg)};
|
||||||
|
restApi.defaultFailedHandler = (msg)=>{bus.$emit('error', msg)};
|
||||||
|
|
||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
render: h => h(App),
|
render: h => h(App),
|
||||||
|
|
Loading…
Reference in New Issue