import { ReactView } from '@tangramino/react';
import { createEngine } from '@tangramino/engine';
// 定义组件
const Button = ({ data, children }) => (
<button onClick={data.onClick} disabled={data.disabled}>
{data.text || children}
</button>
);
const Container = ({ data, children }) => (
<div style={data.style}>{children}</div>
);
// 创建引擎
const engine = createEngine({
elements: {
root: { type: 'Container', props: { style: { padding: 20 } } },
btn1: { type: 'Button', props: { text: 'Click me' } },
},
layout: {
root: 'root',
structure: { root: ['btn1'] },
},
extensions: {},
});
// 渲染
function App() {
return <ReactView engine={engine} components={{ Button, Container }} />;
}