I am using Vue 3, with the script setup and the composition API. I am coming from Svelte, so using the script setup really reminds me of the simplicity of Svelte.
But I'm confused as to why this isn't working.
I have this template code:
<template>
<form @submit.prevent="handleSignIn(email, password)">
...
<button type="submit" :class="{ 'is-loading': isLoading }">Log in</button>
...
</form>
</template>
And this script code:
<script setup lang="ts">
let email: string;
let password: string;
let isLoading: boolean;
const handleSignIn = async (email: string, password: string) => {
isLoading = true;
...
};
</script>
But when clicking the button for the form, the is-loading
class does not get applied. Why is that?