N
N
Natalia2019-06-17 12:19:27
JavaScript
Natalia, 2019-06-17 12:19:27

What is the correct way to use Vue/Vuex to move the id of one element to another on click?

Good afternoon!
Please help me orient myself.
There is a list:

<ul class="tabel-day_menu-type">
    <li v-for='(type,i) in types'
         :key="type.id"
         @click="set_type(type)"
   >
         <span class="icon">
            {{ type.icon }}
        </span>
       <span class="icon_text">{{ type.text }}</span>
    </li>
</ul>

and there is a table of days:
<table class="table">
    <tbody>
          <tr>
               <day-component
                  тут разные атрибуты для компонента
             ></day-component>
         </tr>
       </tbody>
  </table>

The template for one day is placed in a separate day-component, and iterates as many times as necessary.
First, I mark the required cells (the data for the selected cells is collected in a separate array of elements with true values).
I need to click on any of the list items to insert the id of this list item into the selected cells.
How do I properly link all of this using Vue/VUEX (
const store = new Vuex.Store({....
   mutations: {...}
});

Vue.component('day-component',{...
   computed: {
      selected() {
          // собираем все выбранные ячейки и присваиваем им значение true  
           return this.days_selected[ get_day_id([this.day_index, this.w, this.u]) ] === true;
      }
});

var a = new Vue({...
   methods: {...}
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question