yoho-mvc.js
818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
const $ = require('yoho-jquery');
class View {
constructor(ele) {
this.$base = $(ele);
}
on(event, target, fn) {
if (typeof target === 'function') {
fn = target;
target = null;
}
if (this.$base) {
if (target) {
this.$base.on(event, target, fn);
} else {
this.$base.on(event, fn);
}
}
}
emit(event, ...data) {
this.$base.trigger(event, data);
}
}
class Controller {
constructor() {
}
}
function http(options) {
let ajax = $.ajax(options);
ajax.then = ajax.done.bind(ajax);
ajax.catch = ajax.fail.bind(ajax);
ajax.finally = ajax.always.bind(ajax);
return ajax;
}
export {
View, Controller, http
};