<iframe src="" frameborder="0"></iframe>
上面代码可以看出来src需要一个路径引用
这个路径就是html页面
使用相对路径
在容器中使用就可以保证只有这个容器可以改变html页面,其他不改变
以elementui的容器为例
<el-main>
<iframe :src="iframes" frameborder="0" width="100%" height="95%"></iframe>
<iframe src="" frameborder="0"></iframe>
</el-main>
如果引用方法,或者其他参数路径必须在src前面加 :
否则会报错
iframes:"http://localhost:8080/pages/studentlist.html",
menulist:{
menu1:"http://localhost:8080/pages/studentlist.html",
menu2:"http://localhost:8080/pages/gradelist.html",
menu3:"http://localhost:8080/pages/findGrade.html",
},
可以通过vue-on:click()来改变iframes的路径就可以实现组件嵌套