Home  >  Q&A  >  body text

How to pass URL to iFrame in Vue.js

I have no experience with Vue or JS.

I want to pass YouTube link from data() to iFrame.

Can this be done?

If so, what steps need to be taken?

The code below shows what I have so far, although I'm not even sure if it's correct since this is my first time into the world of Vue.js and JS.

I've looked here and elsewhere for ideas on how to do this, but haven't found anything I can use yet.

Any helpful tips are greatly appreciated, thank you.

<template>
   
    <div>
           
          <iframe width="800" height="230" src=this.link></iframe>
                  
    </div>
  
</template>

<script>

import axios from "axios";

export default{
    
     name:"Camera",
     data(){
         return{
         link:"https://www.youtube.com/embed/08Xmfi1QIxc",
         
     };
     },
    methods:{
        
        OnSelectCam(link){
            this.link = link;
        },    
            
        },
   
}   
   
</script>

<style scoped>
</style>

P粉237029457P粉237029457244 days ago302

reply all(1)I'll reply

  • P粉387108772

    P粉3871087722024-02-18 09:21:44

    You need to add : before src and "" in the variable name. You don't need this. within the template.

    reply
    0
  • Cancelreply