Counter
Handling State with eventListener
A simple counter application. This give you basic understanding how to work with DOM eventListener. To attach event we add a Node
attribute
with k-<event>
where <event>
could be one of any types of Events and the value is a string representing one our method in the component class.
import Keet, { html } from 'keet'
class App extends Keet {
el = 'app'
count = 0
add() {
this.count++
}
render() {
return html`
<button id="counter" k-click="add()">
{{count}}
</button>
`
}
}
const app = new App()
Codepen Sample
See the Pen Keetjs - Counter by Shahrul Nizam b. Selamat (@syarul) on CodePen.