- 首先需要將要掛載的
html
文件放到public
文件夾中
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-581434.html
- 路徑的引用形式
<iframe ref="sheet" src="/luckysheet.html" width="100%" height="100%"></iframe>
- 通過(guò)綁定 ref 獲取到 iframe,data為我需要傳遞的數(shù)據(jù),通過(guò) iframes.postMessage 的方法進(jìn)行傳遞。
sentMsgSheet(data) {
const sheetWindow = this.$refs.sheet.contentWindow;
if (sheetWindow) {
sheetWindow.postMessage(data, '*');
}
}
sentMsgSheet([]);
- postMessage 通信具體用法請(qǐng)參考:https://blog.csdn.net/qq_45677671/article/details/128238860
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-581434.html
到了這里,關(guān)于【Vue】 在 vue 中使用 iframe 掛載 html 文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!