js 构造函数方式
如下
function Car(color,door){
this.color = color;
this.doors = door;
this.showColor = function(){
console.log(this.color)
};
}
module.exports = Car
引入的时候
var test = require('./test');
var car = new test("red",1)
car.showColor()
js 构造函数方式
如下
function Car(color,door){
this.color = color;
this.doors = door;
this.showColor = function(){
console.log(this.color)
};
}
module.exports = Car
引入的时候
var test = require('./test');
var car = new test("red",1)
car.showColor()
本文标题:js 构造函数方式 构造类
本文链接:https://www.haomeiwen.com/subject/bklvkqtx.html
网友评论