#VariableTextArea
VariableTextArea 用来输入多行文本和变量表达式。变量会保留 {{ ... }} 字面,适合邮件正文、消息模板等长文本。
如果只需要单行输入,默认用 VariableInput。
#基本用法
import React from 'react';
import { Application, Plugin, VariableTextArea } from '@nocobase/client-v2';
import { Form } from 'antd';
function DemoPage() {
return (
<Form layout="vertical" style={{ maxWidth: 520 }}>
<Form.Item name="content" label="Content">
<VariableTextArea rows={5} namespaces={['$user', '$env']} />
</Form.Item>
</Form>
);
}
class DemoPlugin extends Plugin {
async load() {
this.flowEngine.context.defineProperty('$user', {
value: { name: 'Alice', email: 'alice@example.com' },
meta: {
title: 'Current user',
type: 'object',
properties: {
name: { title: 'Name', type: 'string' },
email: { title: 'Email', type: 'string' },
},
},
});
this.flowEngine.context.defineProperty('$env', {
value: { SMTP_HOST: 'smtp.example.com' },
meta: {
title: 'Environment variables',
type: 'object',
properties: {
SMTP_HOST: { title: 'SMTP_HOST', type: 'string' },
},
},
});
this.router.add('root', {
path: '/',
element: <DemoPage />,
});
}
}
const app = new Application({
router: { type: 'memory', initialEntries: ['/'] },
plugins: [DemoPlugin],
});
export default app.getRootComponent();
import { VariableTextArea } from '@nocobase/client-v2';
<Form.Item name="content" label={t('Content')}>
<VariableTextArea namespaces={['$env', '$user']} rows={10} />
</Form.Item>;#API
| 参数 | 类型 | 说明 |
|---|---|---|
value | string | 当前值 |
onChange | (value: string) => void | 值变化回调 |
disabled | boolean | 是否禁用 |
placeholder | string | 占位文字 |
namespaces | string[] | 限定可选的顶层命名空间 |
extraNodes | MetaTreeNode[] | 追加局部变量节点 |
delimiters | [string, string] | 变量分隔符,默认 ['{{', '}}'] |
className | string | 自定义 class |
style | React.CSSProperties | 自定义样式 |
rows | number | 固定行数 |
maxRows | number | 最大行数 |
#相关链接
- VariableInput — 单行变量输入
- VariableJsonTextArea — 在 JSON 配置里插入变量

