import React, { useRef, useState } from 'react'; // react 18 import { createRoot } from 'react-dom/client'; // react 17 // import { render } from 'react-dom'; import { Button, Input, Option, Player, Preview, Radar, Select, Tab, TabPane, message } from '../index'; import './index.less'; const abilitys = [ { abilityName: '生命', scoreRate: '10', backgroundColor: 'red', fontSize: '30', fontColor: 'blue', }, { abilityName: '攻击', scoreRate: '90' }, { abilityName: '防御', scoreRate: '20' }, { abilityName: '元素精通', scoreRate: '50' }, { abilityName: '暴击率', scoreRate: '80' }, { abilityName: '暴击伤害', scoreRate: '50' }, ]; const App = () => { const [state, setState] = useState({ abilitys }); const previewRef = useRef(); const uploadFile = (e: Event) => { e.preventDefault(); e.stopPropagation(); const preview: Element | undefined = previewRef.current; if (!preview) return message.warning('previewRef.current is undefined'); const uploadFile = document.createElement('input'); uploadFile.setAttribute('type', 'file'); uploadFile.click(); uploadFile.onchange = (e) => { const { files = [] } = uploadFile; if (files && files.length > 0) { preview.setAttribute('src', ''); const file = files[0]; const url = URL.createObjectURL(file); preview.setAttribute('src', url); } }; }; const clickButton = () => { setState({ abilitys }); console.log('fsdafdas'); }; const changeInput = (e) => { console.log('input--->', e); }; // const abilitys = // '[{"abilityName":"生命","scoreRate":"10","backgroundColor":"red","fontSize":"30","fontColor":"blue"},{"abilityName":"攻击","scoreRate":"90"},{"abilityName":"防御","scoreRate":"20"},{"abilityName":"元素精通","scoreRate":"50"},{"abilityName":"暴击率","scoreRate":"80"},{"abilityName":"暴击伤害","scoreRate":"50"}]'; return ( <>

Button

Tab

home user other

Preview

Radar

Input

Select

Player

); }; // react 18 createRoot(document.getElementById('app')).render(); // react 17 // render(, document.getElementById('app'));