import React from 'react';
import { View, Button, Text, getElementById } from '@ray-js/ray';
export default function Demo() {
const handleGetElement = async () => {
const element = await getElementById('targetView');
console.log('节点引用:', element);
};
return (
<View style={{ padding: 20 }}>
<View
id="targetView"
style={{
height: 100,
backgroundColor: '#1890ff',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Text style={{ color: '#fff' }}>目标节点</Text>
</View>
<Button style={{ marginTop: 10 }} onClick={handleGetElement}>
获取节点引用
</Button>
</View>
);
}