{"hidden":false,"children":[{"configs":{"serverScript":"//服务器端代码\nvar myPrivateMember = '私有成员'; //私有成员仅该代码块中可访问\nfunction privateMethod() { //私有方法仅该代码块中可访问\n  return '私有方法';\n}\n\n//公有成员可以在任意代码块或任意引用该模块的模块内引用\n//例如通过添加serverScript控件编写的代码可以使用app内的成员\n//通过模块的importModules属性引用该模块可以在引用的模块内使用app内的成员\n//调用方法时使用app.member();\nWb.apply(app, {\n  myPublicProperty: '公有属性',\n  myPublicMethod: function() {\n    return '公有方法';\n  },\n  moreMethod: function(v1, v2) {\n    return v1 + v2;\n  }\n});","itemId":"module","initScript":"//通常在此处编写模块的服务器端初始化代码，该代码在importModules，serverMethod和serverScript之前运行"},"expanded":true,"children":[{"configs":{"layout":"border","itemId":"viewport1"},"expanded":true,"children":[{"configs":{"itemId":"toolbar1","region":"north"},"expanded":true,"children":[{"configs":{"itemId":"item1","text":"相对独立的代码调用"},"expanded":false,"children":[],"type":"item","events":{"click":"//功能相对独立的代码可以直接在相关事件中编写\napp.myPublicMethod();\nWb.info('item1 clicked.');"}},{"configs":{"itemId":"item2","handler":"app.item2Click","text":"公共代码的调用"},"expanded":false,"children":[],"type":"item","events":{"click":"//如果调用的代码需要引用公共代码或被其他代码引用，可以只设置handler属性为方法接口\n//见handler属性：app.item2Click"}}],"type":"toolbar"},{"configs":{"layout":"center","itemId":"panel1"},"expanded":false,"children":[],"type":"panel"}],"type":"viewport"}],"type":"module","events":{"initialize":"//客户器端代码\nvar myPrivateMember = '私有成员'; //私有成员仅该代码块中可访问\nfunction myPrivateMethod() { //私有方法仅该代码块中可访问\n  return '私有方法';\n}\n\n//模块内的公共方法可以在此定义，app内的成员可以在模块内的任意代码处引用\n//调用方法时使用app.member();\nWb.apply(app, {\n  myPublicProperty: '公有属性',\n  myPublicMethod: function() {\n    return '公有方法';\n  },\n  item2Click: function() {\n    Wb.info('item2 clicked.');\n  }\n});"}}],"roles":{"demo":1},"title":"编程规范","iconCls":"","inframe":false,"pageLink":""}