1.add.js

 1 define(["dojo/_base/declare"], function (declare) {
 2     return declare("aClass", null, {
 3         /*            constructor:function(){
 4          构造函数是声明一个实例时使用,我们这里并没有使用它,所以注释掉
 5          },*/
 6         add: function (num1, num2) {    //类方法
 7             return num1 + num2;
 8         }
 9     });
10 });

 

2.

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 2 <html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 5 <title>Tutorial: Hello Dojo!</title>
 6 </head>
 7 <body>
 8     <h1 id="greeting">Hello</h1>
 9     <script src="dojo/dojo/dojo.js"    data-dojo-config="async: true"></script>
10     <script type="text/javascript">
11         require(['myclass/add'],function(myclass){
12             var m = new myclass();
13             alert(m.add(3,4));
14         });
15     </script>
16 </body>
17 </html>

 

3.

 

posted on 2016-12-30 14:23  Sharpest  阅读(291)  评论(0编辑  收藏  举报