首页 > 其他分享 >前端项目实战肆佰壹拾肆react-admin和material ui-material ui Autocomplete之禁用

前端项目实战肆佰壹拾肆react-admin和material ui-material ui Autocomplete之禁用

时间:2023-09-16 18:05:24浏览次数:35  
标签:index timeSlots material Autocomplete ui import TextField


import * as React from 'react';
import TextField from '@mui/material/TextField';
import Autocomplete from '@mui/material/Autocomplete';

export default function DisabledOptions() {
  return (
    <Autocomplete
      id="disabled-options-demo"
      options={timeSlots}
      getOptionDisabled={(option) =>
        option === timeSlots[0] || option === timeSlots[2]
      }
      sx={{ width: 300 }}
      renderInput={(params) => <TextField {...params} label="Disabled options" />}
    />
  );
}

// One time slot every 30 minutes.
const timeSlots = Array.from(new Array(24 * 2)).map(
  (_, index) =>
    `${index < 20 ? '0' : ''}${Math.floor(index / 2)}:${
      index % 2 === 0 ? '00' : '30'
    }`,
);

运行结果

 

前端项目实战肆佰壹拾肆react-admin和material ui-material ui Autocomplete之禁用_react.js

标签:index,timeSlots,material,Autocomplete,ui,import,TextField
From: https://blog.51cto.com/u_15460007/7495405

相关文章