VueJS/devA/1_hello_vue/index.html

47 lines
963 B
HTML
Raw Normal View History

2024-02-19 15:50:19 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello Vue</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
2024-02-21 08:14:42 +00:00
<p>
{{ message }}
<button @click="changeMessage">Change the message!</button>
</p>
<!-- Vypíše počet sudých čísel v numbers -->
{{ evenNumbersCount }}
2024-02-19 15:50:19 +00:00
</div>
<script>
new Vue({
el: "#app",
data: {
message: "Hello Vue!",
2024-02-21 08:14:42 +00:00
numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
2024-02-19 15:50:19 +00:00
},
2024-02-21 08:14:42 +00:00
2024-02-19 15:50:19 +00:00
methods: {
changeMessage() {
this.message = "Hello World!";
},
},
2024-02-21 08:14:42 +00:00
computed: {
evenNumbersCount() {
return this.numbers.filter((i) => i % 2 === 0).length;
},
},
2024-02-19 15:50:19 +00:00
});
</script>
</body>
</html>