requirejsノート

4841 ワード

<!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");

        }

    }

})