WhatsApp chat

Ejemplo de contador con Owl

Marlon Falcon Hernandez, owl
Back

Este es un ejemplo de un contador con Owl de Odoo.

02-counter

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Hello Owl</title>
    <script src="https://marlonfalcon.com/lib/owl.js"></script>
  </head>
  <body>
    <h1>Owl</h1>
    <script>
        const { Component, xml, useState, mount } = owl;

        class Counter extends Component {
            static template = xml`
              <button t-on-click="() => state.value = state.value + props.increment">
                Click Me! [<t t-esc="state.value"/>]
              </button>`;
          
            state = useState({ value: 0 });
          }
          
          class Root extends Component {
            static template = xml`
              <span>Contador </span>
              <Counter increment="2"/>`;
          
            static components = { Counter };
          }
          
          mount(Root, document.body);
    </script>
  </body>
</html>


mfalconsoft@gmail.com / +34 (662) 47 0645RSS