Javascript 敲除绑定magento 2中的多个viewModels

Javascript 敲除绑定magento 2中的多个viewModels,javascript,knockout.js,requirejs,magento2,Javascript,Knockout.js,Requirejs,Magento2,我一直在使用以下代码绑定其他项目中的viewModels,并且不得不对magento 2进行一些修改。也许我只是看得太久了,但这是我的问题 在下面的代码段中,我得到一个错误:无法将属性“categoryViewModel”设置为undefined,尽管将其注销似乎应该对其进行定义。有什么想法吗 demoController.js define('js/theme',[ 'jquery', 'knockout', 'category', 'product',

我一直在使用以下代码绑定其他项目中的viewModels,并且不得不对magento 2进行一些修改。也许我只是看得太久了,但这是我的问题

在下面的代码段中,我得到一个错误:无法将属性“categoryViewModel”设置为undefined,尽管将其注销似乎应该对其进行定义。有什么想法吗

demoController.js

define('js/theme',[
    'jquery',
    'knockout',
    'category',
    'product',
    'domReady!'
], function ($, ko, categoryView, productView) {
'use strict';

var demoController = {
    init: function(){

        var self = this;
        var shouter = new ko.subscribable();

        categoryView.categoryViewController(shouter);
        productView.productViewController(shouter);

        self.masterVM = (function(){                      
            this.categoryViewModel = new categoryView.categoryViewModel();
            this.productViewModel = new productView.productViewModel();
        })();

        ko.applyBindings(self.masterVM);  

    }
};

demoController.init();
});
categoryView.js

define([
    'jquery',
    'knockout'
], function($, ko) {

var categoryView = {
    categoryViewController: function(shouter){
        //var self = this;
        this.categoryViewModel = function(){
            this.foo = ko.observable('category!');

            console.log('category view', this.foo() );
        };    
    }
};
return categoryView;
});

"严格使用",;这是个问题,但正如我继续了解的,magento 2已经用他们自己的UTIL和实现方式抽象出了一点击倒,所以这个问题是无效的,因为这不是正确的实现方式(我仍在试图弄清楚)看到了这一点得到了支持,如果有人偶然发现这一点,我确实找到了解决方案,尽管这是很久以前的事了,现在可能有更好的方法来实现这一点