Odoo owl dynamically controls subcomponents while learning

Odoo owl dynamically controls subcomponents while learning

The root component controls a child component (DemoComponent). It documents all of its lifecycle methods. Try clicking or via/clicking the two main buttons and see what happens in the console

 

code:

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}:

Guess you like

Origin blog.csdn.net/fqfq123456/article/details/129749351