require.js

<script src="js/require.js" data-main="js/main"></script>   //data-main ,引入主文件


main.js
1 require.config({
2     paths:{
3         jquery:'jquery-1.11.3.min'
4     }
5 });
6 requirejs(['jquery','validate'],function ($,validate) {
7     $('body').css('background-color','red');
8 console.log(validate.checkLength(1,2))
9 });
validate.js
define(['jquery'],function ($) {

    return{
        isEmpty:function () {

        },
        checkLength:function (str1,str2) {
            return str1===str2;
        }
    }
});

  

posted @ 2017-05-12 14:16  夏天的冰淇淋  阅读(140)  评论(0编辑  收藏  举报