简体   繁体   English

使用 Aurelia 检测变量变化

[英]Detecting variable changes with Aurelia

Can i detect changes to a variable with aurelia?我可以用 aurelia 检测变量的变化吗?

I am able to detect the change of a type with @observable, but I am innterested in the change in a variables value ex a = 3 to a = 4 -> detect and do magic()我能够使用@observable 检测到类型的变化,但我对变量值 ex a = 3 到 a = 4 的变化感兴趣 -> 检测并执行魔法()

Normaly you can.通常你可以。 https://discourse.aurelia.io/t/how-to-observe-objects-in-aurelia-using-the-binding-engine/23 https://discourse.aurelia.io/t/how-to-observe-objects-in-aurelia-using-the-binding-engine/23

"The propertyObserver doesn't really have many caveats, the only thing you need to be aware of is you can only watch a single property. You can create multiple propertyObserver calls to observe multiple properties, but you cannot observe objects as a whole (as there are no native events fired when they change)" “propertyObserver 并没有太多的注意事项,你唯一需要注意的是你只能观察一个属性。你可以创建多个 propertyObserver 调用来观察多个属性,但你不能观察整个对象(如更改时不会触发本机事件)”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM