[英]Dojo 2 Is there any after render life cycle hook in dojo2?
I working on Dojo 2 project. 我从事Dojo 2项目。 I know there are not many projects going on Dojo 2 it's difficult to get support for it.
我知道在Dojo 2上进行的项目并不多,很难获得支持。 Anyway I am looking for dojo 2 widget after render life cycle hook?
无论如何,我正在寻找渲染生命周期挂钩后的dojo 2小部件? In React we have:-
在React中,我们有:-
componentDidMount: function() { console.log('Component rendered')},
What about dojo 2 after widget render life cycle hook? 小部件渲染生命周期挂钩之后的dojo 2怎么样?
The runAfterRenders
method isn't intended to be overridden (and should actually be private
) in a widget. 不应在小部件中覆盖
runAfterRenders
方法(并且实际上应该是private
)。 Using the @afterRender
decorator is the correct hook to introspect the the results of a widgets render as per the readme . 使用
@afterRender
装饰器是对自述文件中的小部件渲染结果进行内省的正确钩子。
class MyWidget extends WidgetBase {
@afterRender()
myAfterRender(vnode: VNode) {
// do something with the resulting vnode
vnode.children = [ ...vnode.children, 'Another Text Node' ];
return vnode;
}
protected render() {
return v('div', [ 'text' ]);
}
}
The onAttach
hook is probably a more equivalent lifecycle to reacts componentDidMount
, this is a method lifecycle that can be implemented in the same way as componentDidMount
. onAttach
挂钩可能是更等效的生命周期,以onAttach
componentDidMount
,这是一个方法生命周期,可以与componentDidMount
相同的方式实现。
Hope this helps! 希望这可以帮助!
I got the solution for it: Dojo 2 widget has runAfterRenders life cycle hook which can be trigger after render. 我得到了解决方案:Dojo 2小部件具有runAfterRenders生命周期挂钩,可以在渲染后触发它。
protected runAfterRenders(dNode: DNode | DNode[]): DNode | DNode[] { return dNode; }
Hope this will be helpful. 希望这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.