Files
klienckie_stefanczyk/Lekcja_05/static/cwiczenia/lekcja-4-forms/01.html
T

66 lines
2.1 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 4</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
<div id="app">
<h2>01. Forms</h2>
<form action="/send" method="post" @reset="reset" @submit="submit">
<input type="text" v-model="content" name="tekst" id="tekst">
<input type="reset" value="resetuj">
<input type="submit" value="wyślij">
<input type="checkbox" v-model="block" id="blokuj"><label for="blokuj">Blokuj działania formularza</label>
</form>
<h3 id="message">{{ message }}</h3>
<hr>
<h2>Modyfikator @click.prevent na linku</h2>
<a href="https://vuejs.org" @click="link_click">Przejdź do Vue.js</a>
<input type="checkbox" v-model="blocklink" id="blocklink"><label for="blocklink">Blokada
działania linku</label>
<h3>{{ msg2 }}</h3>
</div>
</body>
<script>
const app = Vue.createApp({
data() {
return {
message: 'formularz',
content: '',
block: true,
blocklink: true,
msg2: 'link'
}
},
methods: {
submit(e) {
e.preventDefault();
this.block ? this.message = 'formularz się nie wysyła' : this.message = 'formularz wysłany';
},
reset(e) {
e.preventDefault();
if (!this.block) this.content = '';
this.block ? this.message = 'formularz się nie resetuje' : this.message = 'formularz zresetowany';
},
link_click(e) {
if (this.blocklink) {
e.preventDefault();
this.msg2 = 'działanie linku zostało zablokowane';
} else {
this.msg2 = 'kliknięto link, następuje przekierowanie';
}
}
}
}).mount("#app");
</script>
</html>