import React, { useRef, useState } from 'react'; import { Text } from 'react-native'; import { CodeInput, Button, Space, CodeInputRef } from '@xrnjs/ui'; import Card from '_global/Card'; import { styles } from './style'; const InteractiveDemo = () => { const codeInputRef = useRef(null); const [currentValue, setCurrentValue] = useState(''); const handleComplete = (code: string) => { console.log('验证码输入完成:', code); }; const handleChange = (code: string) => { setCurrentValue(code); console.log('验证码变化:', code); }; const handleFillRandom = () => { const code = Math.floor(Math.random() * 1000000) .toString() .padStart(6, '0'); codeInputRef?.current?.setCodeValue(code); }; const handleClear = () => { codeInputRef?.current?.setCodeValue(''); }; const handleFillDemo = () => { codeInputRef?.current?.setCodeValue('123456'); }; return ( 手动填充验证码 通过按钮操作验证码输入框 实时监听变化 当前值: {currentValue || '(空)'} ); }; export default InteractiveDemo;