Types
JsxElement
可翻译 JSX 内容中类 HTML 结构化元素的类型定义
概述
JsxElement 表示可翻译 JSX 内容中具有结构的类 HTML 元素。
type JsxElement = {
t?: string; // 标签名
i?: number; // id
d?: GTProp; // GT 数据/属性
c?: JsxChildren; // 子节点
};属性
| 属性 | 类型 | 描述 |
|---|---|---|
t? | string | HTML 标签名 |
i? | number | 内部 ID |
d? | GTProp | GT 属性 |
c? | JsxChildren | 子级内容 |
常用 GT 键名
| GT 键名 | HTML 属性 |
|---|---|
pl | placeholder |
ti | title |
alt | alt |
arl | aria-label |
示例
基本用法
import { JsxElement, Variable } from 'generaltranslation';
// Simple element
const heading: JsxElement = {
t: 'h1',
c: ['欢迎']
};
// With attributes
const button: JsxElement = {
t: 'button',
d: { ti: '提交表单' },
c: ['提交']
};相关类型
JsxChildren- 子元素内容类型JsxChild- 单个子元素
本指南如何?