Skip to content

Commit 286e17f

Browse files
committed
feat(grids): 支持动态修改 grid
close #134
1 parent 34d68a5 commit 286e17f

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/grids/grids.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
const defaultGridProps = {
2+
target: 'self',
3+
url: '',
4+
openType: 'navigate',
5+
delta: 1,
6+
appId: '',
7+
path: '',
8+
extraData: '',
9+
version: 'release',
10+
hoverClass: 'navigator-hover',
11+
hoverStopPropagation: false,
12+
hoverStartTime: 50,
13+
hoverStayTime: 600,
14+
bindsuccess: () => {},
15+
bindfail: () => {},
16+
bindcomplete: () => {}
17+
}
18+
119
Component({
220
options: {
321
addGlobalClass: true,
@@ -10,37 +28,19 @@ Component({
1028
},
1129
grids: {
1230
type: Array,
13-
value: []
31+
value: [],
32+
observer: '_onGridsChange'
1433
}
1534
},
1635
data: {
17-
innerGrids: [],
18-
_defaultGridProps: {
19-
target: 'self',
20-
url: '',
21-
openType: 'navigate',
22-
delta: 1,
23-
appId: '',
24-
path: '',
25-
extraData: '',
26-
version: 'release',
27-
hoverClass: 'navigator-hover',
28-
hoverStopPropagation: false,
29-
hoverStartTime: 50,
30-
hoverStayTime: 600,
31-
bindsuccess() {},
32-
bindfail() {},
33-
bindcomplete() {}
34-
}
36+
innerGrids: []
3537
},
3638
ready() {},
37-
lifetimes: {
38-
attached() {
39-
if (this.data.grids) {
39+
methods: {
40+
_onGridsChange(grids): void {
41+
if (grids) {
4042
this.setData({
41-
innerGrids: this.data.grids.map((grid) =>
42-
Object.assign({}, this.data._defaultGridProps, grid)
43-
)
43+
innerGrids: grids.map((grid) => Object.assign({}, defaultGridProps, grid))
4444
})
4545
}
4646
}

0 commit comments

Comments
 (0)