mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
fix: 修复 input-date 不支持 initApi 问题 (#3761)
This commit is contained in:
parent
bd96b30b08
commit
23759a7126
@ -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}` : ''
|
||||
})
|
||||
});
|
||||
}
|
||||
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}` : ''
|
||||
})
|
||||
});
|
||||
};
|
||||
|
@ -370,18 +370,20 @@ export class DatePicker extends React.Component<DateProps, DatePickerState> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user