mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 11:20:11 +00:00
28 lines
611 B
JavaScript
28 lines
611 B
JavaScript
import React, { PureComponent } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
export default class TextView extends PureComponent {
|
|
static displayName = 'Text';
|
|
|
|
static version = '0.0.0';
|
|
|
|
static propTypes = {
|
|
text: PropTypes.string,
|
|
};
|
|
|
|
render() {
|
|
const { text, ...restProps } = this.props;
|
|
let textNode = text;
|
|
// 强制类型转换
|
|
try {
|
|
textNode = text.toString();
|
|
} catch (e) {
|
|
textNode = '';
|
|
}
|
|
if (window.__ctx && window.__ctx.canvasAppHelper) {
|
|
textNode = textNode || 'Text';
|
|
}
|
|
return <span {...restProps}>{textNode}</span>;
|
|
}
|
|
}
|