D
D
danilr2019-10-03 19:00:19
JavaScript
danilr, 2019-10-03 19:00:19

Why is there an error in the template?

Vue.component('Pict',{
  props: {
    order: String
  },
  computed: {
    picture(){
      return gallery.find(item => item.order === this.order);
    }
  },
  mounted(){
    console.log(this.picture)
  },
  template: `<div class="galery-img-wrapper">
                      <div class="gallery-img" :style="{background: \`url(img/gallery/${picture.img}\`}"></div>
                  </div>`
})

Why does he say that Uncaught ReferenceError: picture is not defined in the template line,
and if you remove it from there, then everything is OK and displays picture in the console?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kovalsky, 2019-10-03
@danilr

https://tuhub.ru/posts/rabota-s-shablonami-v-vue-js-2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question