You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
867 B
30 lines
867 B
import React, { useEffect, useState, useRef } from 'react';
|
|
|
|
function Economics() {
|
|
const iframeRef = useRef(null);
|
|
|
|
useEffect(() => {
|
|
if (iframeRef.current) {
|
|
iframeRef.current.contentWindow.addEventListener('message', (event) => {
|
|
console.log(11111, event.data);
|
|
});
|
|
}
|
|
|
|
return () => {
|
|
if (iframeRef.current) {
|
|
iframeRef.current.contentWindow.removeEventListener('message', (event) => {
|
|
console.log('Received message:', event.data);
|
|
});
|
|
}
|
|
};
|
|
}, []); // 空依赖数组确保只运行一次清理操作
|
|
|
|
return (
|
|
<div>
|
|
<iframe ref={iframeRef} src="http://ds1.chenhaitech.com/chat/2pnkwYTDbuK3HXLL" className='w-[100%] h-screen'/>;
|
|
</div>
|
|
)
|
|
|
|
}
|
|
|
|
export default Economics;
|