'VueJs3 v-if probléme

I have a problem of v-if, I have this button which makes me open a modal and which executes an addClick function

<button
  type="button"
  class="btn btn-primary m-2 fload-end"
  data-bs-toggle="modal"
  data-bs-target="#exampleModal"
  @click="addClick">

In the modal code, I use an if to display either create or update depending on the DepartmentIDjs variable

<button type="button" @click="createClick()" v-if="DepartmentIdJs ==0" class="btn btn-primary">
  Create
</button>
<button type="button" @click="updateClick()" v-if="DepartmentIdJs !=0" class="btn btn-primary">
  Update
</button>

Code JS

let DepartementIdJs = ref('');

const addClick = () => {
  modalTitle = 'Add Departement',
  DepartementIdJs.value = 0;
  DepartementNameJs.value = "";
  console.log(DepartementIdJs.value)
}

return {
  listDepartements,
  DepartementNameJs,
  DepartementIdJs,
  addClick,
  editClick,
  createClick,
  updateClick
}

the console.log gives me 0 while the modal shows me the Update button Can someone explain to me where I made the mistake.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source