带有Requirejs的Knockoutjs - 映射模块

时间:2015-08-19 06:23:53

标签: html mvvm knockout.js requirejs

我希望借助Knockoutjs和requrejs映射到我的模块。 这是我的代码:

HTML:

<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<script data-main="js/index2" src="js/libs/require/require.js"></script>
</head>

<body>
<div id="review"></div>
</body>
</html>

index2.js(我的主要js)

requirejs.config({
    // Path mappings for the logical module names
    paths: {
        'knockout': 'knockout/knockout-3.3.0',
        'jquery': 'jquery/jquery-2.1.3.min',
        'jqueryui-amd': 'jquery/jqueryui-amd-1.11.4.min',
        'signals': 'js-signals/signals.min',
        'crossroads': 'crossroads/crossroads.min'

    },

    shim: {
        'jquery': {
            exports: ['jQuery', '$']
        },
        'crossroads': {
            deps: ['signals'],
            exports: 'crossroads'
        }
    },


});




require([
     'test'
    'knockout',
    'jquery'
],
         function (test, oj, ko, $) 
         $(document).ready(function () {

            ko.applyBindings(test,
                        document.getElementById('review'));



      }

);
);

test.js (模块)

alert("Test done!!!");

0 个答案:

没有答案