前端JS的面向对象写法还是挺好玩的—class继承、实现
class FormDataDTO1 {
id;
name;
sex;
remark;
}
class FormDataDTO2 extends FormDataDTO1 {
age;
address;
}
const formData1 = new FormDataDTO1();
const formData2 = new FormDataDTO2();
const obj1 = {
id: 1,
name: "alee",
sex: "男",
}
Object.keys(obj1).forEach(key => {
formData1.append(key, obj1[key]);
})
本文来自博客园,作者:RHCHIK,转载请注明原文链接:https://www.cnblogs.com/suihung/p/17443481.html