[Vue] iframeを使用してHTMLファイルをvueにマウントする

記事ディレクトリ

  1. まずマウントするhtmlファイルをpublicフォルダーに置く必要があります

ここに画像の説明を挿入

  1. 引用符で囲まれたパスの形式
<iframe ref="sheet" src="/luckysheet.html" width="100%" height="100%"></iframe>
  1. iframe は ref をバインドすることで取得され、データは渡す必要があるデータであり、iframes.postMessage のメソッドを通じて渡されます。
sentMsgSheet(data) {
    
    
	const sheetWindow = this.$refs.sheet.contentWindow;
	if (sheetWindow) {
    
    
		sheetWindow.postMessage(data, '*');
	}
}
sentMsgSheet([]);
  1. postMessage 通信の具体的な使用方法については、https: //blog.csdn.net/qq_45677671/article/details/128238860を参照してください。

おすすめ

転載: blog.csdn.net/qq_45677671/article/details/131721230