[Vuejs]-Vue3: how to retrieve data in vue component from data access object

0👍

I got it: the model itself must be hooked up into vue to be reactive. It works calling the vue-function ‘reactive’ on my dao.

import { reactive } from 'vue';

export default reactive({
  todos: [
    {
      text: 'yadda yadda',
      checked: false,
    },
    {
      text: 'clean up',
      checked: true,
    },
  ],
  getAll() {
    return this.todos;
  },
  deleteTodo(todo) {
    let elementToDelete = this.todos.find((element) => element.text == todo.text);
    this.todos.splice(this.todos.indexOf(elementToDelete, 1));
  },
});

Leave a comment