方法一:
function Tetrio(singleW){
if(singleW == undefined){ singleW = 18; }
this.x = 0; this.y = 0; } Tetrio.prototype.draw = function(context){ } 调用: var tetri = new Tetrio(); tetri.draw(context);
方法二:jason
var AlertBox = { htmlTemplate:'', Show: function (title, content) { var ht = this.htmlTemplate.replace('$title$', title); ht = ht.replace('$content$', content); $('body').append(ht); $('#myModal').modal('show'); }, Close: function () { $('.modal-backdrop').remove(); $('#myModal').remove(); }}; 调用: