It's been a while since using Vue JS and I am currently attempting to render a list of data with a button for each record. When the button is clicked, I would like to conditionally render a component ( in this instance).
Is there a Vue approved way of doing this? Should I be manipulating the DOM? The following doesn't seem to work.
<template>
<div v-for="data in list">
{{ data.bar}}
<button @click="handleClick">
<div v-if="dataset.loading === 'true'">
<loader/>
</div>
<div v-else>
</button>
</div>
</template>
<script setup>
import { loader } from './components'
const list = [{ foo: 'bar'}];
const handleClick = (el) => {
el.dataset.loading = 'true';
setTimeout(3, () => el.dataset.loading = 'false');
};
</script>