VUE使用 iframe 嵌入网页
warning:
这篇文章距离上次修改已过470天,其中的内容可能已经有所变动。
在Vue中嵌入iframe可以通过在模板中添加<iframe>标签并使用v-bind或简写:绑定属性来实现动态属性的绑定。以下是一个简单的例子:
<template>
<div>
<iframe
:src="sourceUrl"
width="100%"
height="600"
frameborder="0"
allowfullscreen
></iframe>
</div>
</template>
<script>
export default {
data() {
return {
sourceUrl: 'https://example.com' // 你希望嵌入的网页URL
};
}
};
</script>在这个例子中,:src="sourceUrl"表示src属性是动态绑定的,Vue会自动将sourceUrl的值赋给src属性。你可以将sourceUrl的值设置为任何你希望嵌入的网页URL。
评论已关闭