属性、className、style 与 Props
import { type FC } from '@rue-js/rue';
const Badge: FC<{ label: string; color?: string }> = (props) => (
<span className="px-2 py-1 rounded-md" style={{ backgroundColor: props.color ?? '#eee' }}>
{props.label}
</span>
);
const AttributesAndProps: FC = () => (
<div className="grid gap-4">
<div id="box" className="border p-2">className 与 id</div>
<div style={{ color: 'tomato', fontWeight: 'bold' }}>内联样式对象</div>
<Badge label="默认" />
<Badge label="自定义色" color="#cde" />
</div>
);
export default AttributesAndProps;