我没有使用 Vue 或 JS 的经验。
我想将 YouTube 链接从 data() 传递到 iFrame。
这可以做到吗?
如果是这样,需要采取哪些步骤?
下面的代码显示了我到目前为止所拥有的内容,尽管我什至不确定它是否正确,因为这是我第一次进入 Vue.js 和 JS 世界。
我已经在这里和其他地方寻找有关如何执行此操作的想法,但尚未找到任何我可以使用的东西。
非常感谢任何有用的提示,谢谢。
<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>            Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
您需要在 src 前添加 :,并在变量名称中添加 ""。你不需要这个。在模板内。