Front End Cross-Frameworks Framework

Copyright © 2020 Tencent

      
import { define, render } from 'omi'

class Store {
  data = {
    count: 1
  }
  sub = () => {
    this.data.count--
  }
  add = () => {
    this.data.count++
  }
}

define('my-counter', _ =>
  <>
    <button onClick={_.store.sub}>-</button>
    <span>{_.store.data.count}</span>
    <button onClick={_.store.add}>+</button>
  </>, {
    use: ['count']
  }
))

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