我在全局标题部分声明了一个哈希:
<script type="text/javascript">
require(["dijit/form/Form", "dijit/form/Button", "dojo/domReady!", "dijit/layout/TabContainer", "dijit/layout/ContentPane", "dijit/form/Select", "dojo/domReady", "dijit/TitlePane", "dijit/form/Textarea", "dojo", "dojox/xml/parser", "dijit/form/ValidationTextB
var dataHash = {};
然后我与它进行交互,并将值放入 for 循环中。但是,当最后一个 for 循环退出时,哈希仍然具有原始内容:
for (key in dataHash) {
for (key2 in dataHash[key]) {
match = null;
contentStr = dataHash[key][key2];
if ( contentStr.match(selEx) ) {
if ( contentStr.match(rEx) ) {
var test = contentStr.replace(rEx, replaceStr.value);
/* here, i change the value at the location dataHash[key][key2] */
dataHash[key][key2] = test;
console.log(dataHash[key][key2]);
}
} else if ( selValStr == "all" ) {
if ( contentStr.match(rEx) ) {
var test = contentStr.replace(rEx, replaceStr.value);
dataHash[key][key2] = test;
}
}
}
}
console.log(JSON.stringify(dataHash)); /* Here, it prints the original content, and not the updated content */