Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Knockout.js 为什么breeze.js不将属性映射为依赖的可观察对象?_Knockout.js_Breeze_Hottowel - Fatal编程技术网

Knockout.js 为什么breeze.js不将属性映射为依赖的可观察对象?

Knockout.js 为什么breeze.js不将属性映射为依赖的可观察对象?,knockout.js,breeze,hottowel,Knockout.js,Breeze,Hottowel,John Papa's在其实体中添加了一个名为isPartial的属性,以确定breeze是否已将整个实体加载到缓存中。当我使用Breeze.WebApi 1.1.3版的教程运行此程序时,一切都正常。但是,我现在正在使用VS 2013 1.1版的HotTower Visual Studio模板运行教程,我发现在breeze 1.4.1版获得未捕获类型错误的情况下保存实体存在问题:boolean不是breeze.debug.js第15124行上的函数 该行正在尝试访问实体上的iPartial属性:

John Papa's在其实体中添加了一个名为isPartial的属性,以确定breeze是否已将整个实体加载到缓存中。当我使用Breeze.WebApi 1.1.3版的教程运行此程序时,一切都正常。但是,我现在正在使用VS 2013 1.1版的HotTower Visual Studio模板运行教程,我发现在breeze 1.4.1版获得未捕获类型错误的情况下保存实体存在问题:boolean不是breeze.debug.js第15124行上的函数

该行正在尝试访问实体上的iPartial属性:

    proto.getProperty = function(propertyName) {
        return this[propertyName]();
    };
早期版本与现在版本的区别在于,当isPartial属性附加到构造函数中时,如下所示:

    metadataStore.registerEntityTypeCtor(
        'Session', function () { this.isPartial = false; }, sessionInitializer);
。。。该属性是一个ko.dependentToServable。在较新的版本中,它是一个简单的属性。我猜这就是导致微风问题的原因。实际上,在首次加载实体时,isPartial属性似乎也是一个DependentToServable,并且save可以正常工作。然而,在这之后的某个时候,它变成了一个简单的属性

下面是一个chrome调试快照,它显示的是before值。

下面是一个chrome调试后的快照,它不起作用。


谢谢你的提示

尝试将breeze.js升级到版本>=1.4.4

其中说版本1.4.4解决了击倒包装缺陷:

修正了淘汰赛中ES5道具不总是正确包装的错误


必须有另一种解释。您将在中看到类似您的示例。例如:

test("add unmapped 'isPartial' property via constructor", 6, function () {
    var store = cloneModuleMetadataStore();

    var Customer = function () {
        // These are simple 'field' properties.
        // Breeze converts them to the right kind of properties  
        // for the prevailing modelLibrary adapter
        // such as KO observable properties.
        this.CustomerID = testFns.newGuidComb();
        this.isPartial = true;
    };

    store.registerEntityTypeCtor('Customer', Customer);

    var em = newEm(store);
    var cust = em.createEntity('Customer'); 

    assertExpectedCustomerCtorProperties(cust);
});

function assertExpectedCustomerCtorProperties(cust) {
    var custType = cust.entityType;
    ok(custType,"'cust' is now an entity");

    // Breeze converted both into KO observables
    ok(typeof cust.CustomerID === 'function',
        "'CustomerID' should be a KO observable");

    ok(typeof cust.isPartial === 'function',
        "'isPartial' should be a KO observable");

    if (!custType) {return;} // no remaining tests would pass

    var propInfo = custType.getProperty('CustomerID');
    ok(propInfo && !propInfo.isUnmapped && propInfo.isPartOfKey,
        "'CustomerID' should be detected as a mapped property");

    propInfo = custType.getProperty('isPartial');
    ok(propInfo && propInfo.isUnmapped,
        "'isPartial' should be an unmapped property");

    var unmapped = custType.unmappedProperties;
    ok(unmapped.length === 1,
        "'isPartial' should be the lone unmapped property");

}
您的第二个屏幕截图显然是针对与第一个不同的实体,因此它不能说服我问题在于breeze

我强烈推荐关于扩展实体的文档,特别是它对自定义构造函数和初始值设定项中属性之间差异的解释


依我看,出于您的目的,您需要构造函数中的isPartial属性

尝试将breeze.js升级到版本>=1.4.4。其中说版本1.4.4解决了击倒包装错误这是个好主意!我更新到1.4.4,然后更新到1.4.13,没有任何差异。谢谢你的建议。@MikeWitt值得一试!没有进一步的信息,很难获得想法。当你一步一步地运行教程时,你会遇到这个问题吗?还是你适应了自己的情况?在第一次成功的过程中,我一步一步地遵循教程。在这个过程中,我用不同的实体替换了其他想法,但概念是相同的。我可能会采取的第一个通行证,工作和升级它的nuget软件包到较新的版本,虽然原来是杜兰达尔1.0和新的是2.0,所以这将增加一些努力。再次感谢。