js模块化

//blog.js
var blog = {};//初始化命名空间

blog.utility =
{
    Version : 'blog.utility version 0.0.1',
    sayHello: function (str)
    {
        alert('hello : '+str +' by ' + this.getVersion());
    },
    getVersion :function ()
    {
         return this.Version;
    }
}

//////////////////////////
//color.js
var color = {};//初始化命名空间

color.utility=
{
    Version : 'color.utility version 0.0.1',
    sayHello: function (str)
    {
        alert('hello : '+str +' by ' + this.getVersion());
    },
    getVersion :function ()
    {
         return this.Version;
    }
}

////////////////////////
//调用
with (color.utility)
{
    sayHello('fzg');
    alert(getVersion());
}

with (blog.utility)
{
    sayHello('abc');
}
posted @ 2009-07-27 09:07  周骏  阅读(259)  评论(0编辑  收藏  举报