odoo owl 边学边练 动态控制子组件
odoo owl 边学边练 动态控制子组件
根组件控制一个子组件(DemoComponent)。它记录其所有生命周期方法。尝试通过单击或通过/单击两个主按钮,然后查看控制台中的内容发生
代码:
js:
const { Component, useState, mount, useComponent, onWillStart, onMounted, onWillUnmount, onWillUpdateProps, onPatched, onWillPatch, onWillRender, onRendered, onWillDestroy} = owl;
function useLogLifecycle() {
const component = useComponent();
const name = component.constructor.name;
onWillStart(() => console.log(`${name}:willStart`));
onMounted(() => console.log(`${name}:mounted`));
onWillUpdateProps(() => console.log(`${name}:willUpdateProps`));
onWillRender(() => console.log(`${name}: