【发布时间】:2018-09-19 04:50:35
【问题描述】:
我正在使用React-Admin 框架并希望将按钮操作组合到单个⋮ 选项按钮。
基本上,我想转这个:
进入这个!
我认为它看起来不那么混乱,⋮ 按钮被广泛用于更多选项。
是否有现成的解决方案?或者如何轻松完成?
编辑:我的解决方案:
MoreOptions.jsx
import * as React from "react";
import { Link, DeleteButton } from "react-admin";
import IconButton from "@material-ui/core/IconButton";
import QueueIcon from "@material-ui/icons/Queue";
import EditIcon from "@material-ui/icons/Edit";
import _objectWithoutProperties from "babel-runtime/helpers/objectWithoutProperties";
const MyEditButton = (props) => (
<IconButton
component={Link}
to={props.basePath + "/" + props.record.id}
color="primary"
aria-label="Edit"
>
<EditIcon style={{ fontSize: '20px' }} />
</IconButton >
);
const MyCloneButton = (props) => (
<IconButton component={Link} to={{
pathname: props.basePath + '/create',
state: {
record: _objectWithoutProperties(props.record, ['id', 'paxDbName'])
}
}} color="primary" aria-label="Clone">
<QueueIcon style={{ fontSize: '20px' }} />
</IconButton>
);
const EditCloneDelete = (props) => {
let a = props;
return <div>
<MyEditButton {...props} />
<MyCloneButton {...props} />
<DeleteButton basePath={props.basePath} record={props.record} resource={props.resource} label=""/>
</div>;
};
export default EditCloneDelete
posts.jsx
import EditCloneDelete from './MoreOptions.jsx';
效果很好!
【问题讨论】:
标签: react-admin