我沒有使用 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>
uj5u.com熱心網友回復:
<iframe width="800" height="230" :src="link"></iframe>
您需要在 src 和""之前添加:到變數名。你不需要這個。模板內。
uj5u.com熱心網友回復:
您需要像這樣將鏈接值系結到 iframe 的 src 屬性
<iframe width="800" height="230" :src=this.link></iframe>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/342597.html
標籤:javascript Vue.js
上一篇:JWT重繪和訪問令牌
