-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue_7_J1.html
60 lines (56 loc) · 1.66 KB
/
vue_7_J1.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
<!DOCTYPE HTML>
<html>
<head>
<title>J1 Practice</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<style>
.formfield{margin-bottom:10px;}
</style>
</head>
<body>
<p>Water Boiling Problem. <a href="https://cemc.uwaterloo.ca/contests/computing/2021/index.html">from the J1 problem hosted by the CCC.</a></p>
<div id="app">
<div class="formfield">
<label>Boiling point: <label> <input v-model="B">
</div>
<div id="result">
<div><label>show diagnostics:</label>
<span v-if="above_sea === true">1 (Above sea level). atmospheric pressure of {{kPa}} kPa.</span>
<span v-else-if="below_sea === true">-1. You are below sea level, with atmospheric pressure of {{kPa}} kPa.</span>
<span v-else="at_sea === true">0. You are at sea level.</span>
</div>
</div>
<script>
var app = new Vue({
el: '#app',
data:{
B:0,
},
computed:{
kPa:function(){
return (5 * this.B - 400);
},
above_sea:function(){
return this.kPa<100;
},
below_sea:function(){
return this.kPa>100;
},
at_sea:function(){
return this.kPa=100;
}
}
});
</script>
<!--
v-model will allow you to quickly bind form elements to the data property.
Make sure to set a default value!
The Computed property can be used like data, except for values that are calculated from data properties.
In this example 'treat_total' is computed from data properties, and 'is_happy' is computed from 'treat_total'.
ASYNCHRONOUS LEARNING EXERCISE : J1
- Find any J1 problem
- Imagine an interface that allows the user to enter data on the webpage
- Build using v-model and computed properties!
-->
</body>
</html>