P
P
panikev2020-04-23 08:08:08
Vue.js
panikev, 2020-04-23 08:08:08

Why is the value not being written to the array?

Hello! Can you please tell me why the value is not being passed to the Vue property? Or maybe there is another option that is different from what I wrote? Thanks in advance!
I also attach the console code:
1115438--
1115438,1773518--
undefined In

export default {
  data() {
    return {
        invoises:{
            profitWork:[]
        }
    }
  },
  methods: {
Summary_Invoices(){
      var plan =[]
      var profitWork = []
         axios
        .get("http://127.0.0.1:8001/api/Invoices/"  ,{  
            params:{
                year :this.year,
                month: this.month
            },
        }) 
        //flat() поднимает массив на уровень выше
        .then((res) => {
           tmp.push(res.data.data)
           for (let index = 0; index < tmp.flat().length; index++) {
                 this.invoises.profitWork.push(tmp.flat()[index].ProfitInWork)
                console.log(this.invoises.profitWork + '--')            
            }
            console.log(this.invoises.ProfitInWork+ " In") //консоль пишет "undefined In" 
        })
        console.log(this.invoises.ProfitInWork + "out")// Эту строку не отрабатывает вообще
  }
}

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