page.js
479 Bytes
import $ from 'jquery';
import qs from 'yoho-qs';
class Page {
constructor() {
this.qs = qs;
this.$event = $(document);
}
on(name, ...cb) {
name = `yohoevent.${name}`;
this.$event.on(name, ...cb);
}
emit(name, ...data) {
name = `yohoevent.${name}`;
this.$event.trigger(name, ...data);
}
ajax(options = {}) {
return Promise.resolve($.ajax(options)).catch(e => {});
}
}
export default Page;