home.page.js
2.29 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var Vue = require('yoho-vue');
var app = require('example/home.vue');
var tpl = require('example/hello.hbs');
var tip = require('../common/tip');
var vm = new Vue({
el: '#app',
components: {
app: app
}
});
console.log(vm);
/* eslint-disable */
// 私有包测试
var qs = require('yoho-qs');
console.log(qs);
var parse = require('yoho-qs/parse'); // 提供解析函数
console.log(parse('q=w&e=r')); // { q: 'w', e: 'r' }
var cookie = require('yoho-cookie');
console.log(cookie.all());
// ES6 test
var test = {
data() {
return {
message: 'test',
message2: 'test2'
};
}
};
// Handlebars/HBS 模版例子
$('#hbs-placeholder').html(tpl({
text: 'Handlerbars'
}));
/* --------------tip demo---------*/
var tipBtn = document.querySelector('#show-tip');
tipBtn.addEventListener('click', function(){
tip('中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中')
});
var Overlay = require('../common/overlay');
var Modal = require('../common/modal');
var customModal = require('../../hbs/example/custom-modal.hbs');
var loading = require('../common/loading');
$('#modal-overlay').click(()=> {
var overlay = new Overlay();
overlay.show();
});
$('#modal-alert').click(()=> {
Modal.alert('自毁系统已经开启,请马上撤离!', '警告');
});
$('#modal-confirm').click(()=> {
Modal.confirm('是否开启自毁系统?', '', function() {
this.hide();
alert('BOOM!');
});
});
// 自定义模态
$('#modal-custom').click(()=> {
const modal = new Modal({
title: '自定义模态对话框',
text: '你可以自定义哦!',
template: customModal,
buttons: [
{
text: '香蕉',
handler: function() {
this.hide();
alert('香蕉');
}
},
{
text: '苹果',
handler: function() {
this.hide();
alert('苹果');
}
}
]
});
modal.show();
});
$('#loading').click(()=> {
loading.show();
setTimeout(()=> {
loading.hide();
}, 3000)
});
/* eslint-enable */