在阅读Dojo的介绍时,我跟随(作为新手)hello world教程。
如何让本地演示工作(通过CDN方法)?在POC之后我会把它放在网络服务器上等等。
步骤1:我将模块复制到demo文件夹中:
CREATE TABLE #TempTable(
city1 VARCHAR(MAX),
city2 VARCHAR(MAX), distance int, flag VARCHAR(1))
INSERT INTO #TempTable (city1, city2, distance,flag)
VALUES ('A', 'B', 200, 'Y'),
('C', 'D', 300, 'N'),
('B', 'A', 200, 'N'),
('B', 'A', 2100, 'Y')
SELECT * FROM #TempTable
WHERE (city1+City2='AB' AND Flag='Y') OR (city1+City2='BA' AND Flag='Y')
然后在当前文件夹中我输入了Html文件:
define([
'dojo/dom'
], function(dom){
var oldText = {};
return {
setText: function (id, text) {
var node = dom.byId(id);
oldText[id] = node.innerHTML;
node.innerHTML = text;
},
restoreText: function (id) {
var node = dom.byId(id);
node.innerHTML = oldText[id];
delete oldText[id];
}
};
});
双击Html文件上的浏览器时,没有看到任何流量,没有更改演示文本并重新更改。
答案 0 :(得分:0)
获得Dojo" hello world"作为新手并不简单。运行。
更改标有** ... **
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial: Hello Dojo!</title>
</head>
<body>
<h1 id="greeting">Hello</h1>
<script>
var dojoConfig = {
async: true,
packages: [{
name: "demo",
**location: 'K:/k_schijf/dojo/demo'**
}]
};
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<script type="text/javascript">
require(
**[ "demo/myDojoModule.js" ],**
function (myDojoModule) {
myDojoModule.setText('greeting', 'Hello Dojo!');
setTimeout(function () {
myDojoModule.restoreText('greeting');
}, 3000);
});
</script>
</body>
</html>
答案 1 :(得分:0)
使用Google的CDN编写“Hello World”示例。
var dojoConfig = {
async: true
};
require(["dijit/form/Button", "dojo/dom", "dojo/domReady!"], function(Button, dom){
// Create a button programmatically:
var myButton = new Button({
label: "Click me!",
onClick: function(){
// Do something:
dom.byId("result1").innerHTML += "Thank you! ";
}
}, "progButtonNode").startup();
});
<link href="https://ajax.googleapis.com/ajax/libs/dojo/1.10.0/dijit/themes/claro/claro.css" rel="stylesheet"/>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<button id="progButtonNode" type="button"></button>
<div id="result1"></div>