can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
37 lines (23 loc) • 1.44 kB
Markdown
Component.extend
can.Component.static
Extends the [can.Component] constructor function.
`can.Component.extend(proto)`
Extends the [can.Component] constructor function with prototype
properties and methods.
{{}} proto An object set as the prototype of the
constructor function. You will typically provide the following values
on the prototype object.
{can.Component.prototype.tag} tag Defines the
tag on which instances of the component constructor function will be
created.
{can.Component.prototype.events} [events] Defines events on
dom elements or observable objects the component listens to.
{can.Component.prototype.helpers} [helpers] Specifies mustache helpers
used to render the component's template.
{can.Component.prototype.viewModel} [viewModel] Specifies an object
that is is used to render the component's template.
{can.Component.prototype.tempate} [template] Specifies the template
rendered within the custom element.
Note that inheriting from components works differently than other CanJS APIs. You can't call `.extend` on a particular component to create a "subclass" of that component.
Instead, components work more like HTML elements. To reuse functionality from a base component, build on top of it with parent components that wrap other components in their template and pass any needed viewModel properties via attributes.
can.