function Button(width, height, bgcolor) {
this.width = width;
this.height = height;
this.bgcolor = bgcolor;
this.but = function (doing) {
console.log(doing);
}
}
var swit1 = new Button('50px', '30px', 'pink');
var swit2 = new Button('20px', '90px', 'black')
console.log(swit1.bgcolor);
console.log(swit1['height']);
console.log(swit2.width);
swit2.but('点点滴滴');
swit1.but('点击行为');
创建一个按钮对象,该对象中需要包含宽,高,背景颜色和点击行为
最新推荐文章于 2022-11-30 19:23:27 发布
关键词由CSDN通过智能技术生成