/
vdele
/
app
Обзор
Документация
Войти
/
vdele
/
app
Код
Вики
Пакеты
0
Релизы
1
Аналитика
dev
src/stores/modal.ts
39 строк
864 B
Vasilii Polshakov
Initial commit
25 мар 2025, 01:21
25 мар 2025, 01:21
6a154a4
Код
Авторство
О чём код?
import { computed, ref, type Component, type Ref, shallowRef, triggerRef } from 'vue'; export function useModalStrore() { const state = ref(false); const body = shallowRef(null) as Ref<{component: Component, props: {}} | null>; const visible = computed(() => state.value); const contentModel = computed(() => body.value); const showModal = () => { state.value = true; }; const hideModal = () => { state.value = false; }; const setBody = (model: {component: Component, props: {}}) => { body.value = model; triggerRef(body); }; const resetBody = () => { body.value = null; triggerRef(body); }; return { //states visible, contentModel, //methods showModal, hideModal, setBody, resetBody }; }