re usage of functions like mixins

==

re usage

import { ref } from 'vue';

export function useModal() {
const showModal = ref(false);

function openModal() {
showModal.value = true;
}

function closeModal() {
showModal.value = false;
}

return {
showModal,
openModal,
closeModal,
};
}


<template>
<div>
<button @click="openModal">Open Modal</button>
<div v-if="showModal" class="modal">
<!-- Modal content here -->
<button @click="closeModal">Close Modal</button>
</div>
</div>
</template>

<script>
import { useModal } from './useModal';

export default {
setup() {
const { showModal, openModal, closeModal } = useModal();

return {
showModal,
openModal,
closeModal,
};
},
};
</script>

<style>
.modal {
/* Modal styles */
}
</style>

==

create folder called composables (like mixins.js )

composables/usenumbers.js




  



=

No comments:

Post a Comment

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...