From 8016f6c08e89d4d2a49ae65603045f1e96159159 Mon Sep 17 00:00:00 2001 From: chenxt <10125295+chen-xintao97@user.noreply.gitee.com> Date: Mon, 19 Jan 2026 10:16:51 +0800 Subject: [PATCH] 处理报错 --- src/components/Common/CommonComponent/index.js | 4 ++-- src/components/Common/CommonHooks/useCommonBase.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Common/CommonComponent/index.js b/src/components/Common/CommonComponent/index.js index ad13037..43582ad 100644 --- a/src/components/Common/CommonComponent/index.js +++ b/src/components/Common/CommonComponent/index.js @@ -82,7 +82,7 @@ export default class CommonComponent extends Component { buttonLoading: false, }; this.lastValue = props.dataValue; - this.firstDataIndex = props.showConfig.sDateFormat === "decimalPoint" ? "d" : props.showConfig.sName.substring(0, 1); /* 控件首字母(数据格式:字符串) */ + this.firstDataIndex = props.showConfig.sDateFormat === "decimalPoint" ? "d" : props.showConfig.sName?.substring(0, 1); /* 控件首字母(数据格式:字符串) */ this.max = props.showConfig.sMaxValue; /* 最大值(数据格式:数字) */ this.min = props.showConfig.sMinValue; /* 最小值(数据格式:数字) */ // 重构修改 @@ -196,7 +196,7 @@ export default class CommonComponent extends Component { dataValue, enabled, sFieldName, bNotEmpty, showName, sDropDownType, } = this.state; if (nextProps.showConfig === undefined || this.props.showConfig === undefined) return; - this.firstDataIndex = nextProps.showConfig.sDateFormat === "decimalPoint" ? "d" : nextProps.showConfig.sName.substring(0, 1); /* 控件首字母(数据格式:字符串) */ + this.firstDataIndex = nextProps.showConfig.sDateFormat === "decimalPoint" ? "d" : nextProps.showConfig.sName?.substring(0, 1); /* 控件首字母(数据格式:字符串) */ if (nextProps.showConfig.sDropDownType === 'const') { /* 常量下拉 */ /* 常量下拉其实只取一次数据就可以啦,去过数据的会给state中的dropDownData赋值,所以dropDownData有值的情况就不需要再获取了 */ diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js index f4d3d77..4fcab04 100644 --- a/src/components/Common/CommonHooks/useCommonBase.js +++ b/src/components/Common/CommonHooks/useCommonBase.js @@ -683,10 +683,10 @@ const useCommonBase = props => { /* 获取数字格式化规范 */ const getFloatNum = sName => { - if (sName.toLowerCase().endsWith("price")) { + if (sName?.toLowerCase().endsWith("price")) { /* 价格 */ return props.app.decimals.dNetPrice; - } else if (sName.toLowerCase().endsWith("money")) { + } else if (sName?.toLowerCase().endsWith("money")) { /* 金额 */ return props.app.decimals.dNetMoney; } else { -- libgit2 0.22.2