Types

JsxElement

可翻译 JSX 内容中类 HTML 结构化元素的类型定义

概述

JsxElement 表示在可翻译的 JSX 内容中具有结构化的类 HTML 元素。

type JsxElement = {
  t?: string;      // 标签名
  i?: number;      // id
  d?: GTProp;      // GT 数据/属性
  c?: JsxChildren; // 子内容
};

属性

属性类型说明
t?stringHTML 标签名
i?number内部标识
d?GTPropGT 属性
c?JsxChildren子级内容

常用 GT 键名

GT 键名HTML 属性
plplaceholder
tititle
altalt
arlaria-label

示例

基本用法

import { JsxElement, Variable } from 'generaltranslation';

// 简单元素
const heading: JsxElement = {
  t: 'h1',
  c: ['欢迎']
};

// 带属性
const button: JsxElement = {
  t: 'button',
  d: { ti: '提交表单' },
  c: ['提交']
};

相关类型

这份指南怎么样?

JsxElement