antd中的拖放导致下拉菜单为空白
创始人
2024-11-07 19:00:49
0

在antd中,如果使用了Drag and Drop,则可能会导致下拉菜单无法正确显示。为了解决这个问题,可以使用以下代码示例:

import { Select } from 'antd';
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';

const { Option } = Select;

const onDragEnd = (result, dropdownOptions, setDropdownOptions) => {
  if (!result.destination) {
    return;
  }

  const items = reorder(
    dropdownOptions,
    result.source.index,
    result.destination.index
  );

  setDropdownOptions(items);
};

const reorder = (list, startIndex, endIndex) => {
  const result = Array.from(list);
  const [removed] = result.splice(startIndex, 1);
  result.splice(endIndex, 0, removed);

  return result;
};

const DragDropSelect = ({ options, setOptions }) => {
  const [dropdownOptions, setDropdownOptions] = useState(options);

  return (
     onDragEnd(result, dropdownOptions, setDropdownOptions)}
    >
      
        {(provided) => (
          
        )}
      
    

相关内容

热门资讯

分享透视!云扑克有透视吗,微乐... 分享透视!云扑克有透视吗,微乐小程序黑科技下载,步骤教程(有挂秘笈)-哔哩哔哩1、金币登录送、破产送...
总结透视!哈糖大菠萝免费辅助器... 总结透视!哈糖大菠萝免费辅助器,微信小程序多乐辅助器,练习教程(有挂猫腻)-哔哩哔哩1.哈糖大菠萝免...
详细透视!wepoker私人局... 详细透视!wepoker私人局辅助挂,微信微乐辅助免费,步骤教程(有挂技术)-哔哩哔哩该软件可以轻松...
有挂透视!wepoker钻石怎... 有挂透视!wepoker钻石怎么看底牌,微乐家乡自建房辅助app,妙计教程(今日头条)-哔哩哔哩1、...
解谜透视!wepoker私人局... 解谜透视!wepoker私人局辅助器怎么用,微乐陕西麻将破解,法门教程(确实有挂)-哔哩哔哩1、解谜...
分享透视!hhpoker德州牛... 分享透视!hhpoker德州牛仔视频,微信小程序微乐辅助器免费下载,妙计教程(有挂细节)-哔哩哔哩小...
解密透视!竞技联盟辅助插件,微... 解密透视!竞技联盟辅助插件,微乐安徽小程序辅助,机巧教程(有挂解密)-哔哩哔哩1、下载好竞技联盟辅助...
专业透视!德普之星透视免费,微... 专业透视!德普之星透视免费,微乐自建房辅助软件有哪些功能,指南教程(有挂分析)-哔哩哔哩1、在德普之...
专业透视!wpk有作弊吗,微乐... 专业透视!wpk有作弊吗,微乐小程序辅助脚本平台,手册教程(有挂存在)-哔哩哔哩1、很好的工具软件,...
开挂透视!wepoker透视脚... 开挂透视!wepoker透视脚本安卓,微乐手游辅助脚本平台,秘籍教程(有挂方略)-哔哩哔哩1、让任何...