Created
November 1, 2019 22:31
-
-
Save cpq/52947accfbbc0a4bfe1c8ec6a7e5f3ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>hiii</title> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<link rel="stylesheet" href="https://unpkg.com/bootstrap@4.3.1/dist/css/bootstrap.min.css" /> | |
<script src="https://unpkg.com/preact@8.4.2"></script> | |
<script src="https://unpkg.com/htm@2.2.1"></script> | |
</head> | |
<body></body> | |
<script> | |
const {h, render, Component} = preact; | |
const html = htm.bind(h); | |
class App extends Component { | |
state = {counter: 0}; | |
inc() { | |
this.setState({counter: this.state.counter + 1}); | |
} | |
render() { | |
return html` | |
<div class="my-5 text-center"> | |
<button class="btn btn-info px-5" onclick=${()=>{this.inc()}}> | |
${this.state.counter} | |
</button> | |
</div> | |
` | |
} | |
}; | |
window.onload = () => render(h(App), document.body); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment