Browse Source

Add loading component for dynamicImport

afc163 7 years atrás
parent
commit
88b85407e9
2 changed files with 13 additions and 1 deletions
  1. 3 1
      config/config.js
  2. 10 0
      src/components/PageLoading/index.js

+ 3 - 1
config/config.js

@@ -19,7 +19,9 @@ export default {
           default: 'zh-CN', // default zh-CN
           baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
         },
-        dynamicImport: true,
+        dynamicImport: {
+          loadingComponent: './components/PageLoading/index',
+        },
         polyfills: ['ie11'],
         ...(!process.env.TEST && os.platform() === 'darwin'
           ? {

+ 10 - 0
src/components/PageLoading/index.js

@@ -0,0 +1,10 @@
+import React from 'react';
+import { Spin } from 'antd';
+
+// loading components from code split
+// https://umijs.org/plugin/umi-plugin-react.html#dynamicimport
+export default () => (
+  <div style={{ paddingTop: 100, textAlign: 'center' }}>
+    <Spin size="large" />
+  </div>
+);