没有加载requirejs的淘汰组件

时间:2016-12-16 01:50:58

标签: jquery knockout.js requirejs

我正在使用带有requirejs AMD加载器的knockoutjs组件,并且出于某种原因组件不会加载。没有错误,脚本都显示加载到页面,但没有显示任何内容。为什么它不在main_ribbon.js视图模型中显示index.html上的main_ribbon.html

的index.html

frame1.ix['002263796']

_layout.html

<mainRibbon></mainRibbon>

require.config.js

<script src=@Url.Content("~/Scripts/app/boot/require.config.js")></script>
<script type="text/javascript" data-main=@Url.Content("~/Scripts/app/boot/init.js") src=@Url.Content("~/Scripts/require.js") ></script>

init.js

var require = {

    urlArgs: "bust=" + (new Date().getTime())
    , waitSeconds: 200
    , paths: {
        waitSeconds: 200,
        "bootstrap": "/Scripts/bootstrap/bootstrap",
        "jquery":"/Scripts/jquery/jquery-3.1.1",
        "knockout": "/Scripts/knockout/knockout-3.4.0",
        "text": "/Scripts/text.js",
        "domReady": "/Scripts/domReady",
        "bindinghandlers":"/Scripts/knockout/bindinghandlers",
        "postbox":"/Scripts/knockout/knockout-postbox",
        "kendo":"/Scripts/kendo/2015.3.1111/kendo.all.min",
        "moment":"/Scripts/moment/moment",
        "toastr":"/Scripts/toastr/toastr"
    },
    shim: {
        "bootstrap": {
            deps:["jquery"]
        },
        "bindinghandlers": {
            deps:["jquery","knockout"]
        },
        "kendo": {
            deps:["jquery"]
        },
        "postbox": {
            deps:["jquery","knockout"]
        }

    }

}

main_ribbon.js

require(['jquery', 'knockout', '/Scripts/app/appViewModel.js', 'postbox', 'bootstrap', 'bindinghandlers','domReady!','/Scripts/app/components/main_filter/main_ribbon.js'], function ($, ko, appViewModel, postbox) {


    ko.components.register('mainRibbon', { require: '/Scripts/app/components/main_filter/main_ribbon' });


    ko.applyBindings(new appViewModel());
})

main_ribbon.html

define(['knockout', '/Scripts/text.js!./main_ribbon.html', 'kendo', '/Scripts/app/models/m_main_ribbon.js', '/Scripts/app/constants/cont.js', 'postbox'],function (ko, main_ribbon, k, model, cont) {

        function rvm() {
            var self = this;

            self.test = ko.observable("test");

            model.data();

            console.log("myloading");

            cont.xhr_get("/RibbonFilter/MainFilter").done(function (allData) {


            });

        }// end vm
        return { viewModel: rvm, template: main_ribbon };
    });

0 个答案:

没有答案