1、栗子
interface per{
contractId?:string | any,
orgId?:string | any,
contractName?:string | any,
orgName?:string| any,
post?:string| any,
phone?:string| any,
email?:string| any,
}
const contactObj:per = {
orgId: '',
contractName: '',
orgName: '',
post: '',
phone: '',
email: '',
};
const [dataSource, setDataSource] = useState<per[]>([contactObj]);
const addConcatA = async () => {
dataSource.push(contactObj);
setDataSource(dataSource);
};
const addConcatB = async () => {
// @ts-ignore
setDataSource([...dataSource, { ...contactObj}]);
};
2. 执行 addConcatA 数据不会更新,通过执行addConcatB 数据生效 ,解决方案:通过解构的方式实现,原因:目前不是很确定,找到问题再更新
QQ技术交流群:707 196 135 (大前端技术交流群)
674

被折叠的 条评论
为什么被折叠?



