目录

loadJavaScript()

功能

将脚本从url加载到文档中。

语法

scripter.loadJavaScript(url, loadedCallback, errorCallback)

参数

范例

Example: 加载一个js文件,成功输出 “load success”。

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script>
    <script>
    require.config({
        baseUrl: "./",
        packages: [{
            name: "skylark",
            location: "../../../src/skylark"
        }, ]
    });
    </script>
</head>

<body>
    <strong></strong>
    <script>
    require(["skylark/scripter", "skylark/datax", "skylark/finder"], function(scripter, datax, finder) {
       scripter.loadJavaScript(["/lib/skylark/fx.js"], function(fx) {
            datax.text(finder.find("strong"), "load success");
        });
    });
    </script>
</body>

</html>