admin 管理员组文章数量: 1086019
Can I change the value of an input to the src of an iframe. Is this possible with VueJS I am picturing:
<input id="input"/>
<iframe src="wele.html"></iframe>
let vm = new Vue ({
data: {
src: "wele.html",
},
});
document.getElementById("input").value = /* src from vm.data? */
Can I change the value of an input to the src of an iframe. Is this possible with VueJS I am picturing:
<input id="input"/>
<iframe src="wele.html"></iframe>
let vm = new Vue ({
data: {
src: "wele.html",
},
});
document.getElementById("input").value = /* src from vm.data? */
Share
Improve this question
asked Jan 7, 2020 at 19:18
VisalVisal
4771 gold badge5 silver badges10 bronze badges
1
- You should probably use Vue's ref to access the element – user9161752 Commented Jan 7, 2020 at 20:20
2 Answers
Reset to default 5You should be able to do something like:
<input id="input"/>
<iframe :src="iframeSrc"></iframe>
let vm = new Vue ({
data: {
iframeSrc: "wele.html",
},
});
But you need to bind Vue to some parent element, like <div id="app"></div>
new Vue({
el: "#app",
...
}
Vue.ponent('base-iframe', {
data: function() {
return {
url: 'https://example.'
}
},
template: '<iframe :src="url" />'
})
new Vue({
el: '#ponents-demo'
})
<script src="https://cdnjs.cloudflare./ajax/libs/vue/2.6.10/vue.min.js"></script>
<div id="ponents-demo">
<base-iframe />
</div>
本文标签: javascriptBind IFrame SRC to VueJS DataStack Overflow
版权声明:本文标题:javascript - Bind IFrame SRC to VueJS Data - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744002069a2516629.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论