Skip to content

Commit 84a394a

Browse files
Merge pull request #5 from dennythecoder/dev
Dev
2 parents bee8e61 + 6828a5d commit 84a394a

File tree

4 files changed

+10748
-21
lines changed

4 files changed

+10748
-21
lines changed

example/example.html

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
<test-component></test-component>
99
<static-component></static-component>
10-
<static-component></static-component>
11-
<static-component></static-component>
10+
<static-component is-fahrenheit></static-component>
11+
1212
</div>
1313

1414

1515

16-
<script src="https://unpkg.com/vue"></script>
16+
<script src="./vue.js"></script>
1717
<script src="../dist/vue-sap.js"></script>
1818
<script>
1919
Vue.component('test-component',{
@@ -26,20 +26,35 @@
2626

2727

2828
Vue.component('static-component',{
29+
props:{
30+
isFahrenheit:{
31+
type: Boolean,
32+
required: false,
33+
default: false
34+
}
35+
},
2936
statics:{
30-
styleObj:{backgroundColor:'#aaa'}
37+
temp:0
3138
},
32-
methods:{
33-
onClick(){
34-
const so = this.styleObj;
35-
if(so.backgroundColor === 'red'){
36-
so.backgroundColor = 'blue';
37-
}else{
38-
so.backgroundColor = 'red';
39+
computed:{
40+
displayTemp:{
41+
get(){
42+
if(this.isFahrenheit){
43+
return this.temp * 9 / 5 + 32;
44+
}else{
45+
return this.temp;
46+
}
47+
},
48+
set(newValue){
49+
if(this.isFahrenheit){
50+
this.temp = (newValue - 32) * 5 / 9;
51+
}else{
52+
this.temp = newValue;
53+
}
3954
}
4055
}
4156
},
42-
template: `<div :style="styleObj" @click="onClick" style="width:40px; height:40px; border-radius: 20px 20px;"></div>`
57+
template: `<label>{{isFahrenheit ? 'Fahrenheit' : 'Celsius'}}<input type="text" v-model="displayTemp" /></label>`
4358
});
4459

4560
new Vue({

0 commit comments

Comments
 (0)