0
点赞
收藏
分享

微信扫一扫

【React】使用 antd 加载组件实现 iframe 的加载效果

90哦吼 2024-07-24 阅读 10

文章目录

  • 代码实现:
import { Spin } from 'antd';
import { useState } from 'react';

export default function () {
  const [loading, setLoading] = useState(true);
  return (
    <div style={{ position: 'relative', height: '100%' }}>
      <Spin
        style={{ position: 'absolute', marginLeft: '40vw', marginTop: '40vh' }}
        spinning={loading}
        tip="加载页面资源中..."
      />
      <iframe
        src={url}
        allow="fullscreen"
        onLoad={() => {
          setLoading(false);
        }}
        style={{
          height: '100%',
          width: '100%',
          border: 'none',
        }}
      />
    </div>
  );
}
举报

相关推荐

0 条评论