Nuxt JS. Не строится DOM из methods

Рейтинг: 1Ответов: 1Опубликовано: 22.06.2023

Простой код. Закомментированный код отрабатывает при загрузке vue, а точно такой же, по кнопке - нет. В консоли ответ в json есть. Знаю, что решение постое, но не могу его найти.

<template>
  <div>
    <div v-for="sale in sales" :key="sale.id" class="blog">  
          <div class="blog-title">{{ sale.ntab }}</div>
    </div>
    <div class="col-sm-6">
        <button class="btn btn-primary" type="submit" @click.prevent="submitForm">Запрос</button>
      </div>
  </div>
  </template>
  
  <script>
  export default {
    data() {
    return {
      sales : '',
    }
  },
   // async asyncData({$axios}) {
  //    let  data = await $axios.$get(`http://localhost:8000/api/sales/`);
 //     console.log(data.results)
 //     return {
 //       sales: data.results,
 //     }
 //   },
    methods: {
    async submitForm({$axios}) {
      let response = await this.$axios.$get(`http://localhost:8000/api/sales/`)
      console.log(response.results)
      return {
        sales: response.results,
      }
    }      
    }
  }
  </script>

Ответы

▲ 0Принят

Вместо

      return {
        sales: response.results,
      }

нужно

      this.sales = response.results;