A
A
Artem00712017-04-07 13:21:55
Vue.js
Artem0071, 2017-04-07 13:21:55

How to get rid of reactivity?

I have a component with tickets, I want to get rid of reactivity. Let me explain.
There is a table:

<tr v-for="(oneTicket, index) in allTickets">
                      <td>{{index + 1}}</td>
                      <td>{{oneTicket.title}}</td>
                      <td>{{oneTicket.price}}</td>
                      <td>{{oneTicket.quantity}}</td>
                      <td>{{oneTicket.description}}</td>
                    </tr>

In data() I wrote the data:
ticket:{
            title: null,
            price: 0,
            quantity: 0,
            description: null
          },
          allTickets: []

And the add method:
methods: {
        addTicket(){
            let ticket = this.ticket; //пытался избавиться от реактивности
            this.allTickets.push(ticket);
        },

And actually 4 fields for filling in data
<input v-model="ticket.title">
<input v-model="ticket.price">
<input v-model="ticket.quantity">
<textarea v-model="ticket.description">
<button @click="addTicket"

When I fill in a new one, the whole table changes. How to make sure that the data is not overwritten in the table when I write something new?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-04-07
@Artem0071

This is how you need to get rid of:
I.e. create a new object instead of assigning a reference to the object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question