我似乎無法得到關於申報工作的道場例子。例如鏈接:http://dojotoolkit.org/reference-guide/1.9/dojo/_base/declare.html#id3道場 - 申報功能
這是我如何設置它:
/index.html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.2/dojo/dojo.js" data-dojo-config="async: true"></script>
<script src="/my/Employee.js"></script>
<script src="/my/Person.js"></script>
<script>
var dojoConfig = {
parseOnLoad: true,
packages: [{
"name": "my",
"location": location.pathname.replace(/\/[^/]+$/, "") + "/my"
}
]
};
</script>
<script>
require(["my/Person"], function (Person)
{
var folk = new Person("phiggins", 42, "Tennessee");
});
require(['my/Employee'], function (Employee)
{
var matt = new Employee("Matt", 33, "California", 1000);
console.log(kathryn.askForRaise(), matt.askForRaise()); // 3600, 20
});
</script>
<title></title>
</head>
<body>
</body>
</html>
/my/Person.js
define(["dojo/_base/declare"], function (declare)
{
return declare(null, {
constructor: function (name, age, residence)
{
this.name = name;
this.age = age;
this.residence = residence;
}
});
});
/我的/僱員。 js
define(["dojo/_base/declare", "my/Person"], function (declare, Person)
{
return declare(Person, {
constructor: function (name, age, residence, salary)
{
// The "constructor" method is special: the parent class (Person)
// constructor is called automatically before this one.
this.salary = salary;
},
askForRaise: function()
{
return this.salary * 0.02;
}
});
});
我tr ied在所有回調方法中設置一箇中斷點(return declare ...)並且它永遠不會進入那裏。它也不會進入require block的回調。
任何幫助表示讚賞
你會希望
Dojo ...很少使用的很棒的框架...不公平 –