omi/packages/omi-html
dntzhang 2f2a799dae update example of omi-html 2018-11-22 09:55:33 +08:00
..
dist update omi-html 2018-11-21 14:27:57 +08:00
examples/counter update example of omi-html 2018-11-22 09:55:33 +08:00
.eslintrc add omi-html 2018-11-21 12:45:51 +08:00
README.md update readme 2018-11-21 14:49:08 +08:00
index.js update omi-html 2018-11-21 14:26:06 +08:00
package.json update omi-html 2018-11-21 14:27:57 +08:00
webpack.config.js omi-html - v0.2.2 2018-11-21 14:11:49 +08:00

README.md

omi-html

Using htm in omi.

→ online demo

Usage

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

define('my-counter', class extends WeElement {
  static observe = true

  data = {
    count: 1
  }

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

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

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

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

Syntax highlighting

License

MIT © dntzhang