1
class basicClass {
constructor(id, rejion, name) {
this.id = id;
this.rejion = rejion;
this.name = name;
}
config() {
return this;
}
buy() {
let urlBasic = "https://www.xxxxx.";
for (let item in this) {
urlBasic += ${item}=${this[item]}&
;
}
return urlBasic.substr(0, urlBasic.length - 1);
}
}
class ECSClass extends basicClass {
constructor(instance, ...params) {
super(...params);
this.instance = instance;
}
}
class RDSClass extends basicClass {
constructor(dbType, ...params) {
super(...params);
this.dbType = dbType;
}
}
let basic = new ECSClass(12, 3, 4, 5);
console.log(basic.config());
console.log(basic.buy());
let basic = new RDSClass(123, 34, 42, 54);
console.log(basic.config());
console.log(basic.buy());