Dojo 调用 js中的方法

前端之家收集整理的这篇文章主要介绍了Dojo 调用 js中的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
HTML代码
<!DOCTYPE html>
<html>
<head>
<Meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
	<Meta charset="utf-8" /> 
    <script src="../js/jquery.min.js"></script>
    <script src="../js/jquery.js"></script>
    <script src="../js/dojo.js"></script>
</head>
<body>
    <button type="button" id="btn">按钮</button>
    <script>
        var dojoConfig = {
            async: true,//此代码寄存器的“演示”包正确的位置,所以我们可以从CDN加载Dojo的同时还能够加载本地模块
            packages: [{
                name: "DojoTest",location: location.pathname.replace(/\/[^/]*$/,'') + '/DojoTest'
            }]
        };

        require(['DojoTest/forDojoTest'],function (dj) {
            dj.setText("btn","NEW BUTTON");
            setTimeout(function () { dj.responseText("btn") },3000);
        });


    </script>
</body>
</html>
 

JS代码

define(['dojo/dom'],function (dom) {
    var oldText = {};
    return {
        setText: function (id,text) {
            var node = dom.byId(id);
            oldText[id] = node.innerHTML;
            node.innerHTML = text;
        },responseText: function (id) {
            var node = dom.byId(id);
            node.innerHTML = oldText[id];
            delete oldText[id];
        }
    }
})

猜你在找的Dojo相关文章