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
865 B

  1. import React, { useEffect, useState, useRef } from 'react';
  2. function Industry() {
  3. const iframeRef = useRef(null);
  4. useEffect(() => {
  5. if (iframeRef.current) {
  6. iframeRef.current.contentWindow.addEventListener('message', (event) => {
  7. console.log(11111, event.data);
  8. });
  9. }
  10. return () => {
  11. if (iframeRef.current) {
  12. iframeRef.current.contentWindow.removeEventListener('message', (event) => {
  13. console.log('Received message:', event.data);
  14. });
  15. }
  16. };
  17. }, []); // 空依赖数组确保只运行一次清理操作
  18. return (
  19. <div>
  20. <iframe ref={iframeRef} src="http://ds1.chenhaitech.com/chat/qcAjlNGBDeqI168Z" className='w-[100%] h-screen'/>;
  21. </div>
  22. )
  23. }
  24. export default Industry;