封装自己的js框架入门

(function(){
    if(!window.project){
        window.project={}
    }
    
    window.project={
        init:function(){
            alert("test")
        },
        show:function(){
            alert("test2")
        }
    }
})();


function Range(){}
Range.prototype={
    init:function(){
        alert("init");
    },
    show:function(){
        alert("show");
    }
};

function RangeChildren(){}
RangeChildren.prototype=Range.prototype;
RangeChildren.prototype.add=function(){
    alert("add");
};

页面调用

function Range(){}
Range.prototype={
	init:function(){
		alert("init");
	},
	show:function(){
		alert("show");
	}
};

function RangeChildren(){}
RangeChildren.prototype=Range.prototype;
RangeChildren.prototype.add=function(){
	alert("add");
};

body

<button onclick="project.show()">点击</button>
<button onclick="test()">Test2</button>

 

posted on 2016-07-26 11:00  lihfei89  阅读(424)  评论(0编辑  收藏  举报

导航