I
I
Ibishka2020-03-03 14:23:21
Vue.js
Ibishka, 2020-03-03 14:23:21

I have several pictures how to get the width of all and write a specific width to each one?

export default {
  data() {
    return {
      galleries: [],
      videos: [],
      galleriesList: [
        {
          img: "gallery1.jpg"
        },
        {
          img: "gallery2.jpg"
        },
        {
          img: "gallery3.jpg"
        },
        {
          img: "gallery4.jpg"
        }
      ],
      videosList: [
        {
          img: "video1.jpg",
          video: "video1.mp4"
        },
        {
          img: "video2.jpg",
          video: "video2.mp4"
        },
        {
          img: "video3.jpg",
          video: "video3.mp4"
        }
      ]
    };
  },
  methods: {
    getGalleries() {
      this.galleries = this.galleriesList;
    },
    getVideos() {
      this.videos = this.videosList;
    },
    insertVideo(e) {
      // <source src="${require(`@/assets/videos/video${event.target.dataset.video}.ogv`)}" type="video/ogg">
      // e.target.parentNode.classList.remove("fill");
      e.target.parentNode.innerHTML = `<video autoplay controls><source src="${require(`@/assets/videos/${event.target.dataset.video}`)}" type="video/mp4">Your browser does not support the video tag.</video>`;
      this.$parent.onPlay();
    },
    qw() {
      alert(this.$refs.preview.clientWidth);
    }
  },
  created() {
    this.getGalleries();
    this.getVideos();
  },
  mounted() {
    this.qw();
  }
};

Outputs undefined. Although he sees the elements.

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