Skip to content

Regular中如何实现高阶组件 #224

@Qquanwei

Description

@Qquanwei

例如我需要实现一个组件挂载时给body加上一个类名的高阶组件。

const withBodyClass = Component => 
Component.extend({
  init() {
     document.body.class = 'classname';
  }
  destory() {
    document.body.class = '';
  }
})

但是,貌似Regular的组件并不支持这样。如果我传入一个

const MyComponent = Regular.extend({
    name: 'MyComponent'
    ...
})

const HOBodyClass = withBodyClass(MyComponent);

全局的MyComponent还是原始的定义。

请问Regular中是如何实现这类组件的?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions