Front End Cross-Frameworks Framework

v6.6 © 2019 Tencent

      
import { render, WeElement, define } from 'omi'

define('my-counter', class extends WeElement {
  count = 1

  static css = `
    span{
        color: red;
    }`

  sub = () => {
    this.count--
    this.update()
  }

  add = () => {
    this.count++
    this.update()
  }

  render() {
    return (
      <div>
        <button onClick={this.sub}>-</button>
        <span>{this.count}</span>
        <button onClick={this.add}>+</button>
      </div>
    )
  }
})

render(<my-counter />, 'body')