[英]Odoo difference in Javascript extend and include
In Odoo one can extend
or include
on a class (in Javascript). 在Odoo中,可以
extend
或include
在类(在Javascript中)。 What is the difference in Odoo between extend
and include
? Odoo在
extend
和include
之间有什么区别?
When you extend
, instances from the parent class remain untouched, but instances from the new child class will have the extended features. extend
,父类中的实例保持不变,但新子类中的实例将具有扩展功能。
OTOH, when you include
, you are adding the new features to the prototype of the parent class, which means that automatically all instances of such class include the extended behavior. OTOH,当您
include
,您正在将新功能添加到父类的原型中,这意味着此类的所有实例都会自动包含扩展行为。
You know, JS works with prototypes; 你知道,JS使用原型; i wrote about class and instance just to make it easier to understand.
我写了关于类和实例的文章只是为了让它更容易理解。 😉
😉
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.