首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更改Ant Design的默认加载纺纱器

如何更改Ant Design的默认加载纺纱器
EN

Stack Overflow用户
提问于 2020-06-01 09:22:35
回答 2查看 7.5K关注 0票数 2

我搜索了,但似乎找不出如何更改使用V4生成的默认加载旋转器。我用了发电机运行了npm create umi myApp。有一个默认的四圈旋转器,我想用一个定制的旋转器来替换。

默认加载程序位于以下位置:

代码语言:javascript
复制
#/myApp/config/config.ts

...
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
...

当我根据Ant的客户查询文档修改PageLoading/index.tsx页面时。我一直在犯这个错误。

代码语言:javascript
复制
Error: Element type is invalid: expected a string (for built-in components)
or a class/function (for composite components) but got: object.

Check the render method of `LoadableComponent`.

原始PageLoading/index.tsx

代码语言:javascript
复制
import { PageLoading } from '@ant-design/pro-layout';

// loading components from code split
// https://umijs.org/plugin/umi-plugin-react.html#dynamicimport
export default PageLoading;

改性PageLoading/index.tsx

代码语言:javascript
复制
import { Spin } from 'antd';
import { LoadingOutlined } from '@ant-design/icons';

const antIcon = <LoadingOutlined style={{ fontSize: 24 }} spin />;

const CustomSpinner = <Spin indicator={antIcon} />

export default CustomSpinner;

我需要做些什么才能使它成为LoadableComponent?谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-07-17 16:49:38

返回值应该是一个组件。函数或类组件。

这样做是可行的:

代码语言:javascript
复制
import react from 'react';
import { Spin } from 'antd';
import { LoadingOutlined } from '@ant-design/icons';

const antIcon = <LoadingOutlined style={{ fontSize: 24 }} spin />;

// Return value should be component
const CustomSpinner = () => <Spin indicator={antIcon} />

export default CustomSpinner;
票数 2
EN

Stack Overflow用户

发布于 2022-08-11 20:43:59

一种新的方法。可以在全局范围内定义默认的自旋元素。

代码语言:javascript
复制
//top of app.tsx

import { Spin } from 'antd';
Spin.setDefaultIndicator(<div>Loading</div>);

蚂蚁设计参考https://ant.design/components/spin/#Static-Method

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62129180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档