Before AMD, we could use methods directly in chrome/firebug command line like: dojo.byId()
or dijit.byId()
etc.
But in AMD form, how we will get methods available in a module in command line?
You can just put the complete syntax on one line like this:
require(["dojo/dom"], function(dom) { console.log(dom.byId("search")); });
and for dijit.byId()
:
require(["dijit/registry"], function(registry) { console.log(registry.byId("search")); });
You can also put the modules in the global space by putting the following snippet in your html :
<script type="dojo/require">
dom : "dojo/dom",
registry : "dijit/registry"
</script>
See http://dojotoolkit.org/reference-guide/1.9/dojo/parser.html#declarative-require
That way, you can use the modules directly in the chrome console. eg :
registry.byId("someId")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.