【发布时间】:2021-08-20 11:49:57
【问题描述】:
如果我有这样的课程:
common.ts(在 mixins 文件夹下):
export class Common { }
基础组件.ts:
@Mixin([Validation])
export abstract class BaseComponent extends Common implements Validation {...}
base-list-type-component.ts:
@Injectable()
class BaseListComponent<T, U> extends BaseComponent implements OnInit, OnDestroy {...}
component-with-template.component.ts:
@Component({
selector: "app-component-with-template",
templateUrl: "./component-with-template.component.html"
})
export class ComponentWithTemplate extends BaseListComponent<DataInterface, DataService> {...}
在 Angular 中使用这样的继承是一种好习惯吗?关于性能,使用继承还是创建服务哪个更好?
【问题讨论】:
标签: angular angular-components javascript-inheritance