forked from wechat-miniprogram/miniprogram-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.js
50 lines (44 loc) · 905 Bytes
/
button.js
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
const types = ['default', 'primary', 'warn']
const pageObject = {
data: {
defaultSize: 'default',
primarySize: 'default',
warnSize: 'default',
disabled: false,
plain: false,
loading: false
},
onShareAppMessage() {
return {
title: 'button',
path: 'page/component/pages/button/button'
}
},
setDisabled() {
this.setData({
disabled: !this.data.disabled
})
},
setPlain() {
this.setData({
plain: !this.data.plain
})
},
setLoading() {
this.setData({
loading: !this.data.loading
})
}
}
for (let i = 0; i < types.length; ++i) {
(function (type) {
pageObject[type] = function () {
const key = type + 'Size'
const changedData = {}
changedData[key] =
this.data[key] === 'default' ? 'mini' : 'default'
this.setData(changedData)
}
}(types[i]))
}
Page(pageObject)