omi/packages/omi-html
张磊 170beb96e4 omi-html - using latest htm 2019-01-09 13:10:55 +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 omi-html - using latest htm 2019-01-09 13:10:55 +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