我想创建的mui对话框只是使用多核,React,reactDom没有jsx语法,想要创建对话框
zbq4xfa01#
使用React.createElement代替JSX。示例:
React.createElement
import Button from '@mui/material/Button'; import DialogTitle from '@mui/material/DialogTitle'; import DialogContent from '@mui/material/DialogContent'; import Dialog from '@mui/material/Dialog'; import {createElement, useState, Fragment} from 'react'; export default function Demo() { const [open, setOpen] = useState(false); return createElement(Fragment, {}, createElement(Button, {onClick(){setOpen(true)}}, 'Open Dialog'), createElement(Dialog, {open, onClose(){setOpen(false)}}, createElement(DialogTitle, {}, "Dialog Title"), createElement(DialogContent, {}, "Content")) ); }
1条答案
按热度按时间zbq4xfa01#
使用
React.createElement
代替JSX。示例: