Home > database >  Vue3 v-if do not see changes of the variable in condition
Vue3 v-if do not see changes of the variable in condition

Time:01-27

<template>
    <EditStudentModal v-if="showModal==='show'"/>
    <div v-for="student in prop.students" :key="student.id">
        <StudentItem
            :student="student"
            @editStudent="openEditModal"
        />
    </div>
</template>

part of my

let showModal = ref('');

const openEditModal = (data) => {
    showModal = 'show';
}

the value of showModal variable changes after triggering the @editStudent event, but v-if does not see it

CodePudding user response:

change showModal = 'show' to showModal.value = 'show'

  • Related