Mixin - MDN Web Docs Glossary: Definitions of Web-related terms 编辑
A mixin is a class or interface in which some or all of its methods and/or properties are unimplemented, requiring that another class or interface provide the missing implementations. The new class or interface then includes both the properties and methods from the mixin as well as those it defines itself. All of the methods and properties are used exactly the same regardless of whether they're implemented in the mixin or the interface or class that implements the mixin.
The advantage of mixins is that they can be used to simplify the design of APIs in which multiple interfaces need to include the same methods and properties.
For example, the WindowOrWorkerGlobalScope
mixin is used to provide methods and properties that need to be available on both the Window
and WorkerGlobalScope
interfaces. The mixin is implemented by both of those interfaces.
Learn more
General knowledge
- Mixin on Wikipedia
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论