-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
61 lines (57 loc) · 1.75 KB
/
index.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
61
<!DOCTYPE html>
<html>
<head>
<title>Exemplo de página HTML com Vue</title>
<!-- Inclui o CDN do Vue -->
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<main id="app">
<form @submit.prevent="submitForm">
<h1 class="texto-primario">LOGIN</h1>
<label for="usuario">Usuário</label>
<input v-model="usuario" type="text" id="usuario" name="usuario">
<label for="senha">Senha</label>
<input v-model="senha" type="password" id="senha" name="senha">
<button>Logar</button>
</form>
<p>Logado? {{ logado }}</p>
</main>
<script>
const app = Vue.createApp({
data() {
return {
message: 'Este é um exemplo de mensagem do Vue',
usuario: 'luan',
senha: 'luan',
logado: false
}
},
methods: {
async submitForm() {
try {
const response = await fetch('http://localhost:8000/auth/token/', {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: this.usuario,
password: this.senha
})
}).then((response => {
if(response.ok) {
this.logado = true
}
}))
} catch(error) {
console.log(error)
}
}
}
})
app.mount('#app')
</script>
</body>
</html>