VueJS lekcja 3
This commit is contained in:
1 parent
0a308d6145
commit
58990da7c8
6 files changed
+434
No files matched your search
@@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Lekcja 3</title>
|
||||
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">
|
||||
<div @click="divclick">click</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<select @change="schange">
|
||||
<option>opt1</option>
|
||||
<option>opt2</option>
|
||||
<option>opt3</option>
|
||||
<option>opt4</option>
|
||||
<option>opt5</option>
|
||||
<option>opt6</option>
|
||||
</select>
|
||||
<p v-text="select_value"></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<input type="range" @change="rchange" value="50" min="0" max="100" step="1">
|
||||
<p v-text="range_value"></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<input type="checkbox" @change="cchange">
|
||||
<p v-text="checkbox_value"></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<button @click="icounter">powiększ licznik</button>
|
||||
<p v-text="counter"></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<button @click="cpower">potęguj 2 do licznika</button>
|
||||
<p v-text="power"></p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
select_value: 'opt1',
|
||||
range_value: 50,
|
||||
checkbox_value: false,
|
||||
counter: 0,
|
||||
power: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
divclick() {
|
||||
alert("KLIK");
|
||||
},
|
||||
schange(e) {
|
||||
app.select_value = e.target.value;
|
||||
},
|
||||
rchange(e) {
|
||||
app.range_value = e.target.value;
|
||||
},
|
||||
cchange(e) {
|
||||
app.checkbox_value = !app.checkbox_value;
|
||||
alert(app.checkbox_value);
|
||||
},
|
||||
icounter() {
|
||||
app.counter++;
|
||||
},
|
||||
cpower() {
|
||||
app.power = 2 ** app.counter;
|
||||
}
|
||||
}
|
||||
}).mount("#app");
|
||||
|
||||
</script>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user