material-ui_设置Material-UI骨架加载器的最短显示时间

material-uiLet’s configure a Material-UI Skeleton Loader to display for 1 second OR the loading time of an API call, whichever is greater. 让我们将Material-UI骨架加载器配置为显示1秒或API调用的加载时间,以较大者为准。 Typically use...
摘要由CSDN通过智能技术生成

material-ui

Let’s configure a Material-UI Skeleton Loader to display for 1 second OR the loading time of an API call, whichever is greater.

让我们将Material-UI骨架加载程序配置为显示1秒或API调用的加载时间,以较大者为准。

Typically users don’t need a loading icon if load time is less than 1 second, but if you are uncertain how long an API may take to respond, you may want to avoid flashing a component on the screen before showing a loading indicator.

通常,如果加载时间少于1秒 ,则用户不需要加载图标,但是如果您不确定API会花费多长时间,则可能需要避免在显示加载指示器之前在屏幕上闪烁组件。

Alternatively, you could show nothing at all for one second before choosing to show a loading indicator. Or you could show the indicator immediately, which is what I will

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Material-UI的Select组件中使用树结构,你可以使用Recursive Tree组件。以下是一个示例代码: ```jsx import React from 'react'; import PropTypes from 'prop-types'; import { makeStyles } from '@material-ui/core/styles'; import TreeView from '@material-ui/lab/TreeView'; import TreeItem from '@material-ui/lab/TreeItem'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import ChevronRightIcon from '@material-ui/icons/ChevronRight'; import FormControl from '@material-ui/core/FormControl'; import InputLabel from '@material-ui/core/InputLabel'; import Select from '@material-ui/core/Select'; const data = { id: 'root', name: 'Parent Node', children: [ { id: '1', name: 'Child Node 1', children: [ { id: '2', name: 'Subchild Node 1', }, { id: '3', name: 'Subchild Node 2', }, ], }, { id: '4', name: 'Child Node 2', children: [ { id: '5', name: 'Subchild Node 3', }, { id: '6', name: 'Subchild Node 4', }, ], }, ], }; const useStyles = makeStyles({ root: { height: 240, flexGrow: 1, maxWidth: 400, }, }); function renderTreeItems(items) { return ( <> {items.map((item) => ( <TreeItem key={item.id} nodeId={item.id} label={item.name}> {Array.isArray(item.children) ? renderTreeItems(item.children) : null} </TreeItem> ))} </> ); } function RecursiveTreeView(props) { const classes = useStyles(); const { onChange, value } = props; const handleChange = (event) => { onChange(event.target.value); }; return ( <FormControl className={classes.formControl}> <InputLabel htmlFor="tree-select">Select</InputLabel> <Select native value={value} onChange={handleChange} inputProps={{ name: 'tree-select', id: 'tree-select', }} > <option value="" /> {renderTreeItems([data])} </Select> </FormControl> ); } RecursiveTreeView.propTypes = { onChange: PropTypes.func.isRequired, value: PropTypes.string.isRequired, }; export default function SelectWithTree() { const [value, setValue] = React.useState(''); const handleChange = (newValue) => { setValue(newValue); }; return ( <RecursiveTreeView onChange={handleChange} value={value} /> ); } ``` 在这个示例中,我们首先定义了一个树形数据结构,然后使用`renderTreeItems()`函数递归渲染树形结构。最后,在`RecursiveTreeView`组件中,我们使用`FormControl`和`Select`组件来显示树形结构,并在选择时触发`onChange`事件。你可以根据自己的需要来修改这个示例。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值