当前位置 : 主页 > 手机开发 > harmonyos >

前端项目实战贰佰零壹react-admin+material ui-react-admin之warnWhenUnsavedChanges

来源:互联网 收集:自由互联 发布时间:2023-08-26
import * as React from "react";import {Button,Typography,Box} from '@mui/material';import { Edit, ListButton,useRecordContext, ShowButton, SimpleForm, TextInput,TopToolbar, DateInput, ReferenceManyField, Datagrid, TextField, DateField, Edit


import * as React from "react";
import {Button,Typography,Box} from '@mui/material';
import { Edit, ListButton,useRecordContext, ShowButton, SimpleForm, TextInput,TopToolbar, DateInput, ReferenceManyField, Datagrid, TextField, DateField, EditButton, required } from 'react-admin';
const PostTitle = () => {
    const record = useRecordContext();
    return <span>Post {record ? `"${record.name}"` : '1111'}</span>;
};

export const SimpleFormEdit = () => {
    const PostEditActions = () => (
        <TopToolbar>
            <ShowButton />
            {/* Add your custom actions */}
            <ListButton />
            <Button color="primary" >Custom Action</Button>
        </TopToolbar>
    );
    const Aside = () => (
        <Box sx={{ width: '200px', margin: '1em' }}>
            <Typography variant="h6">Instructions</Typography>
            <Typography variant="body2">
                Posts will only be published once an editor approves them
            </Typography>
        </Box>
    );
    return(
        <Edit  >
        <SimpleForm warnWhenUnsavedChanges>
        <TextInput source="name" validate={[required()]} fullWidth />
            <TextInput source="sex" multiline={true} label="Short description" />
            <TextInput source="salary" multiline={true} label="Short description" />
        </SimpleForm>
    </Edit>
    )
    
}
网友评论