diff --git a/mock/cfc/mock/form/initData.js b/mock/cfc/mock/form/initData.js index a4616b213..92849ec80 100755 --- a/mock/cfc/mock/form/initData.js +++ b/mock/cfc/mock/form/initData.js @@ -1,28 +1,27 @@ - const tpls = { - tpl1: { - name: 'Amis Renderer', - author: 'fex', - }, - tpl2: { - name: 'Renderer', - author: 'amis', - }, - tpl3: { - name: 'Amis', - author: 'renderer', - } + tpl1: { + name: 'Amis Renderer', + author: 'fex', + date: 1646323200 + }, + tpl2: { + name: 'Renderer', + author: 'amis' + }, + tpl3: { + name: 'Amis', + author: 'renderer' + } }; - -module.exports = function(req, res) { - res.json({ - status: 0, - msg: '', - data: Object.assign({}, (tpls[req.query.tpl] || tpls.tpl1), { - infoId: req.query.id, - date: Math.round(Date.now() / 1000), - info: req.query.keywords ? `你输入的关键子是 ${req.query.keywords}` : '' - }) - }); -} \ No newline at end of file +module.exports = function (req, res) { + res.json({ + status: 0, + msg: '', + data: Object.assign({}, tpls[req.query.tpl] || tpls.tpl1, { + infoId: req.query.id, + date: Math.round(Date.now() / 1000), + info: req.query.keywords ? `你输入的关键子是 ${req.query.keywords}` : '' + }) + }); +}; diff --git a/src/components/DatePicker.tsx b/src/components/DatePicker.tsx index 89d5930b5..336183b8e 100644 --- a/src/components/DatePicker.tsx +++ b/src/components/DatePicker.tsx @@ -370,18 +370,20 @@ export class DatePicker extends React.Component { const newState: any = { value: normalizeValue(props.value, props.format) }; - // 相对值和公式是 didUpdate 的时候才更新 + if ( - typeof prevValue === 'string' && - (prevValue.startsWith('+') || - prevValue.startsWith('-') || - prevValue.startsWith('$')) + typeof prevValue === 'undefined' || // initApi 的情况 + (typeof prevValue === 'string' && // 公式的情况 + (prevValue.startsWith('+') || + prevValue.startsWith('-') || + prevValue.startsWith('$'))) ) { newState.inputValue = normalizeValue(this.props.value, this.props.format)?.format( this.props.inputFormat ) || ''; } + this.setState(newState); } }