当前位置:Gxlcms > JavaScript > js中直接声明一个对象的方法

js中直接声明一个对象的方法

时间:2021-07-01 10:21:17 帮助过:39人阅读

var ctrl = { 
init: function(){ 
this.a(); 
this.b(); 
}, 
name : "zs", 
a: function(){ 
alert("aa"); 
}, 
b: function(){ 
alert("bb"); 
} 
}; 
var str = ctrl.name; 
console.info(str); //zs 
ctrl.init(); //弹出aa,bb

人气教程排行