vanyahuk
@vanyahuk

Почему компонент VUE.jsне видит свойства?

Почему компонент не видит свойства product?

Vue.component('catalog-content-wrap', {
    template: '#catalog-content-wrap',

    data : function () {
        return{
                        products    : [],

                        filters     : [],

                        message     : 'hello'
                        }
    },

    mounted () {
        this.get_catalog_content();
    },

    methods : {

        get_catalog_content : function () {

            this.loader = true;

            this.$http.post( Website.href ).then(response => {
                this.products = response.body.products;
                console.log( response.body.products )
            } );

        }
    }
})

<script type="text/x-template" id="catalog-content-wrap">
        <div class="row no-margin catalog-content-wrap" id="catalog-content-wrap" >

            <div class="col-md-4 col-sm-4 col-xs-6 mob-product" v-for="product in products">
                {{product}}
</div>
</div>
             
    </script>
  • Вопрос задан
  • 343 просмотра
Пригласить эксперта
Ответы на вопрос 1
walovari
@walovari
full stack web developer
this.$http.post( Website.href ).then(response => {
                this.products = response.body.products;
                console.log( response.body.products )
            } );

Запрос идет на нужный url ? (Что в website.href ?)
this.$http.post( Website.href ).then(response => {
                this.products = response.body.products;
                console.log( response.body.products )
            },response => {
                console.error(response)
            }
 );

добавьте вторую функцию для обработки случая с ошибкой
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
14 мая 2024, в 12:43
50000 руб./за проект
14 мая 2024, в 12:34
5000 руб./за проект