-
Notifications
You must be signed in to change notification settings - Fork 0
/
6.html
102 lines (82 loc) · 1.98 KB
/
6.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<style>
.bottom-spaced { margin-bottom: 10px; }
.container { margin: 20px;}
</style>
</head>
<body class="container" id="app">
<div class="row">
<div class="col-sm-6">
<div v-for="plan in plans">
<plan :plan="plan" :active.sync="active"></plan>
</div>
</div>
<div class="col-sm-6">
</div>
</div>
<template id="plan">
<div class="row bottom-spaced">
<div class="col-xs-2">
<strong>{{plan.name}}</strong>
<span>{{plan.price}}/month</span>
</div>
<div class="col-xs-6">
<span @click="setActive" v-show="!isActive" class="btn {{className}}">
{{buttonName}}
</span>
<span v-else class="btn btn-primary">Active Plan</span>
</div>
</div>
</template>
<script>
var vm = new Vue({
el: "#app",
data: {
plans: [
{ name: 'Enterprice', price: 100},
{ name: 'Pro', price: 80},
{ name: 'Personal', price: 40},
{ name: 'Free', price: 0}
],
active: {}
},
components: {
plan: {
template : "#plan",
props: ['plan', 'active'],
methods: {
setActive: function() {
this.active = this.plan;
}
},
computed: {
buttonName: function(){
var name = 'Upgrade';
if (this.active.price > this.plan.price) {
name = 'Downgrade';
};
return name;
},
isActive: function() {
return this.active.name == this.plan.name;
},
className: function(){
var className = 'btn-success';
if (this.active.price > this.plan.price) {
className = 'btn-danger';
};
return className
}
}
}
}
})
</script>
</body>
</html>