可能的错误:Breeze.js 1.5-除非您指定“写入"选项,否则无法将值写入ko.computed [英] Possible Bug: Breeze.js 1.5 -- Cannot write a value to a ko.computed unless you specify a 'write' option

查看:63
本文介绍了可能的错误:Breeze.js 1.5-除非您指定“写入"选项,否则无法将值写入ko.computed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我发现了一个错误...

I think I found a bug...

刚刚更新到新的Breeze.JS v1.5,现在出现以下错误:

Just updated to the new Breeze.JS v1.5 and now I'm getting the following error:

Error: Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.
   at dependentObservable (http://localhost:54663/Scripts/knockout-3.2.0.debug.js:1712:17)
   at setDpValueSimple (http://localhost:54663/Scripts/breeze.debug.js:5083:5)
   at defaultPropertyInterceptor (http://localhost:54663/Scripts/breeze.debug.js:4945:13)
   at write (http://localhost:54663/Scripts/breeze.debug.js:16415:25)
   at dependentObservable (http://localhost:54663/Scripts/knockout-3.2.0.debug.js:1710:17)
   at proto.setProperty (http://localhost:54663/Scripts/breeze.debug.js:16454:13)
   at Anonymous function (http://localhost:54663/Scripts/breeze.debug.js:7918:21)
   at proto._updateTargetFromRaw (http://localhost:54663/Scripts/breeze.debug.js:7891:9)
   at updateEntity (http://localhost:54663/Scripts/breeze.debug.js:14782:9)
   at mergeEntity (http://localhost:54663/Scripts/breeze.debug.js:14755:13)

有什么想法是解决此问题的最佳方法吗?

Any ideas the best way to fix this real quick?

更新:这是我在breeze.debug.js中第5083行的拟议修复:

rawAccessorFn(newValue);

为此:

if (ko.isWriteableObservable(rawAccessorFn))
    rawAccessorFn(newValue);

不确定此修复程序有任何潜在问题,但对我有用:)

Not sure of any underlying issues with this fix but it works for me :)

更新2:现在在breeze.debug.js v1.5.1中的第5167行修复此问题

更新3:现在在breeze.debug.js v1.5.2中的5191行修复此问题

我们可以在源代码中实现此FIX吗?

Can we get this FIX implemented in the source?

推荐答案

那么那是未映射的属性,是吗?而它的价值是如何确定的?通过其他属性和数据的计算,是吗?

So tho is an unmapped property, yes? And its value is determined how? By computation from other properties and data, yes?

那么谁在尝试设置值?你还是微风?如果是微风,在什么情况下?

So who is trying to set the value? You or Breeze? If Breeze, under what circumstances?

我问所有这些问题,因为对我来说,默默地忽略设置RO属性的尝试比抛出更好,这对我来说并不明显.在我看来,柯在告诉您一些重要的事情.

I ask all of these questions because it is not obvious to me that silently ignoring an attempt to set a RO property is better than throwing. Seems to me that Ko is telling you something important.

如果微风将属性设置为您无法触摸的某个内部阶段(例如,在查询结果处理或实体导入期间),我会做出这样的更改.

I would make such a change if breeze were setting the property in some internal phase that you can't touch (e.g. during query result processing or entity import).

对jsfiddle或plunker进行小的复制确实会有所帮助.

A small repro on jsfiddle or plunker would really help.

谢谢.

这篇关于可能的错误:Breeze.js 1.5-除非您指定“写入"选项,否则无法将值写入ko.computed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆