二货爱吃白萝卜
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
1 additions and
4 deletions
-
components/cascader/demo/lazy.tsx
|
|
@ -1,12 +1,11 @@ |
|
|
|
import React, { useState } from 'react'; |
|
|
|
import { Cascader } from 'antd'; |
|
|
|
import React, { useState } from 'react'; |
|
|
|
|
|
|
|
interface Option { |
|
|
|
value?: string | number | null; |
|
|
|
label: React.ReactNode; |
|
|
|
children?: Option[]; |
|
|
|
isLeaf?: boolean; |
|
|
|
loading?: boolean; |
|
|
|
} |
|
|
|
|
|
|
|
const optionLists: Option[] = [ |
|
|
@ -31,11 +30,9 @@ const App: React.FC = () => { |
|
|
|
|
|
|
|
const loadData = (selectedOptions: Option[]) => { |
|
|
|
const targetOption = selectedOptions[selectedOptions.length - 1]; |
|
|
|
targetOption.loading = true; |
|
|
|
|
|
|
|
// load options lazily
|
|
|
|
setTimeout(() => { |
|
|
|
targetOption.loading = false; |
|
|
|
targetOption.children = [ |
|
|
|
{ |
|
|
|
label: `${targetOption.label} Dynamic 1`, |
|
|
|