alibaba / x-render

🚴‍♀️ 阿里 - 很易用的中后台「表单 / 表格 / 图表」解决方案
https://xrender.fun
6.98k stars 988 forks source link

Object 和array的title 如何修改或者把国际化添加进去呢 #1413

Closed xyy7260 closed 10 months ago

xyy7260 commented 11 months ago
image

因为我们产品要国际化所以 要把i18加入进去。


   "items": {
        "type": "object",
        "properties": {
          "xh_yy_zt": {
            "param": "xh_yy_zt",
            "title": "xh_yy_zt",     
            "type": "object",
            "labelWidget": "CustomLabel",   // 这里 
            "descWidget": "CustomDesc",
             .......
lhbxs commented 11 months ago

你这里不是已经自定义 labelWidget 吗

xyy7260 commented 11 months ago

@lhbxs labelWidget 不能获取到 Object 和array。 所以labelwidget 不行

xyy7260 commented 11 months ago
import { I18n } from '@/components/i18';

const styles = {
  color: '#00000073',
  lineHeight: '22px',
  marginLeft: '5px',
  fontWeight: '400',
  fontSize: '14px',
};
const CustomLabel = (props: any) => {
  const { schema } = props;
 console.log(props) // 不能获取到 Object 和array 信息
  return (
    <div>
      {I18n(schema.title)}
      {schema.description ? <span style={styles}>{`(${I18n(schema.description)})`}</span> : null}
    </div>
  );
};

export default CustomLabel;
RGaius commented 10 months ago
import { I18n } from '@/components/i18';

const styles = {
  color: '#00000073',
  lineHeight: '22px',
  marginLeft: '5px',
  fontWeight: '400',
  fontSize: '14px',
};
const CustomLabel = (props: any) => {
  const { schema } = props;
 console.log(props) // 不能获取到 Object 和array 信息
  return (
    <div>
      {I18n(schema.title)}
      {schema.description ? <span style={styles}>{`(${I18n(schema.description)})`}</span> : null}
    </div>
  );
};

export default CustomLabel;

建议自己实现tableList吧,框架层面没有适配

xyy7260 commented 10 months ago

目前想到 一个方法 自定义 Object 和 array widget, 如果没有好的方式我就关闭此问题了