Files
2026-11-02 14:35:11 +01:00

51 lines
1.3 KiB
HTML

<!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>
<style>
.active {
color: cornflowerblue;
}
</style>
</head>
<body>
<div id="app">
<h2>@click | @keyup.enter</h2>
<ul>
<li v-for="item in items" v-bind:class="{ 'active': item.checked }">{{ item.text }} <input type="checkbox"
v-model="item.checked"></li>
</ul>
<input type="text" placeholder="dodaj element" v-model="temp_text" @keyup.enter="add_item">
<button @click="add_item">add item</button>
</div>
</body>
<script>
const app = Vue.createApp({
data() {
return {
temp_text: '',
items: [
{ text: "element 1", checked: true },
{ text: "element 2", checked: false },
{ text: "element 3", checked: false },
]
}
},
methods: {
add_item() {
app.items.push({ text: app.temp_text, checked: false });
}
}
}).mount("#app");
</script>
</html>