import React, { useState } from 'react'; import { Button, Portal, Space } from '@xrnjs/ui'; import style from './style'; import Card from '_global/Card'; const Api = () => { // 该组件销毁时自动移除动态渲染绑定 const [key, setKey] = useState(null); const handleCreate = () => { if (!key) { const newKey = Portal.add( ); setKey(newKey); } }; const handleRemove = () => { if (key) { Portal.remove(key); setKey(null); } }; // Portal 内部的组件在根节点渲染 return ( ); }; export default Api;