// 父类子类在一个js文件
// main.js
var BaseResult = require('./point').ctor();
BaseResult.getInfo();
var BaseResult1 = require('./point').ctorCPoint();
BaseResult1.getInfo();
BaseResult1.getInfo1();
// point.js
class Point{
constructor(){
}
getInfo(){
console.log('hello world');
}
}
class CPoint extends Point {
constructor(){
super();
}
getInfo1(){
console.log('hello world1');
}
}
module.exports = {
ctor:function() {
return new Point();
},
ctorCPoint:function() {
return new CPoint();
}
}
// 父类子类在不同js文件
// main.js
var BaseResult1 = require("./cpoint").ctor();
BaseResult1.getInfo();
BaseResult1.getInfo1();
// point.js
class Point{
constructor(){
}
getInfo(){
console.log('hello world');
}
}
module.exports = {
ctor:function() {
return new Point();
},
Point
}
// cpoint.js
const { Point } = require("./point");
class CPoint extends Point {
constructor(){
super();
}
getInfo1(){
console.log('hello world1');
}
}
module.exports = {
ctor:function() {
return new CPoint();
},
}