-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.js
71 lines (66 loc) · 1.73 KB
/
render.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var compcol ={
template:'<div class=\"col\"><div :class="[stylesheet]" class=\"col-color\">{{number}}</div></div>',
props:['number'],
data:function(){
return {stylesheet:0};
},
beforeUpdate:function(){
console.log("before")
this.getClass(this.number);
},
updated:function() {
console.log("update");
},
created:function(){
this.getClass(this.number);
},
methods:{
getClass:function(i){
var styleDic = {'0':'zero','2':'two','4':'four','8':'eight','16':'sixteen','32':'thirtytwo','64':'sixtyfour','128':'ohte','256':'thfs','512':'fht','1024':'ottf','2048':'ttfe'};
//return {stylesheet:styleDic[this.number]};
this.stylesheet = styleDic[i];
}
}
};
var Game = new Vue({
el:"#app",
data:{
items:game1.show(),
score:game1.getScoreRank().score,
record:game1.getScoreRank().record,
isFailed:game1.isFailed()
},
computed:{
},
components:{
'col-component':compcol
},
methods:{
updateCondition:function(){
this.items = game1.show();
this.score = game1.getScoreRank().score;
this.record = game1.getScoreRank().record;
this.isFailed = game1.isFailed();
},
goLeft:function(){
game1.moveLeft();
this.updateCondition();
},
goRight:function(){
game1.moveRight();
this.updateCondition();
},
goUp:function(){
game1.moveUp();
this.updateCondition();
},
goDown:function(){
game1.moveDown();
this.updateCondition();
},
newGame:function(){
game1.newGame();
this.updateCondition();
}
}
});