Skip to content

Instantly share code, notes, and snippets.

@cpq
Created December 18, 2020 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpq/7ccb7c8a017d78f8eac145a6fe7df278 to your computer and use it in GitHub Desktop.
Save cpq/7ccb7c8a017d78f8eac145a6fe7df278 to your computer and use it in GitHub Desktop.
<!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://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"></script>
</head>
<body></body>
<script type="module">
import { h, Component, render } from 'https://unpkg.com/preact?module';
import htm from 'https://unpkg.com/htm?module';
const html = htm.bind(h);
class App extends Component {
state = {count: 0};
render(props, state) {
const onclick = ev => this.setState({count: state.count + 1});
return html`
<div class="m-5">
<div class="jumbotron text-center display-2">${state.count}</div>
<button class="btn btn-block btn-info px-5" onclick=${onclick}>
click me
</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