How to implement dynamic src for iFrame in Nuxt 3

31 Views Asked by At

I use Vue3, Nuxt3 and bootstrap5. I need to render iframe dynamically. But iframe does not shown, there is not src attribute at all.

//template

<div>
 <iframe
  :src="currentDoc.src"
  allowfullscreen="true"
  frameborder="0"
  scrolling="no"
  width="560"
  height="400"
  :title="currentDoc.title">
 </iframe>
</div>

/// script

import Docs from '@/.../docs';

export default {
  data() {
    return {
      docs: Docs,
      currentDoc: {},
    }
  },

 mounted() {
  this.id = this.$route.params.id;
  this.currentDoc = this.docs.find(doc => doc.id == this.id);
 }
}
0

There are 0 best solutions below