[Vuejs]-Finding nested array to store new data in Vue

0👍

I am still learning about Vuex as well, so hopefully my answer will be able to help you.

If your route is projects/:id, you can easily get the id by this.$route.params.id in your ‘Add Todo’ method. Then you can pass the id into your mutation, and search the projects by id.

Your method:

methods: {
   submitInitialTodo() {
      // your mutation for Vuex
      this.addInitialTodo(this.$route.params.id);
   }
}

In your mutation:

mutations: {
   addInitialTodo(state, project_id) {
      // search project list by id and push to array
   }
}

Leave a comment