Skip to content

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

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中是如何实现这类组件的?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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