项目引入iframe
一、主程序
页面引入iframe
<iframe
ref="iframe"
src="http://localhost:5555/#/login"
frameborder="0"
scrolling="no"
/>
iframe传参/自适应
mounted () {
const mapFrame = this.$refs.iframe
const iframeWin = mapFrame.contentWindow
if (mapFrame.attachEvent) { // 兼容浏览器判断
mapFrame.attachEvent('onload', function () {// 定义接收方法,方便精准接收
iframeWin.postMessage(
{
iframeClick: 'getParams',
params: { // 传递的值
key: getToken()
}
},
'*'
)
})
} else {
mapFrame.onload = function () {
iframeWin.postMessage(
{