requirejs 笔记

时间:2021-02-06 08:37:00
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Examples</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <script data-main="a" src="require.js"></script>
    <script>
    (function() {
        require.config({
            paths: {
                a: "a"
            }
        })
        require([ "a"], function(aa) {
            aa.fun1()
        })
    })()
    </script>
</head>

<body>
    <div>aaaaaaaaaaaa</div>
</body>

</html>
define(function() {
    return {
        fun1: function() {
            alert("it works");
        }
    }
})