Skip to content

Instantly share code, notes, and snippets.

@tivac
Created April 11, 2017 06:18
Show Gist options
  • Save tivac/cd7c5afda1eeef6412eb7387ed962dbf to your computer and use it in GitHub Desktop.
Save tivac/cd7c5afda1eeef6412eb7387ed962dbf to your computer and use it in GitHub Desktop.
Mithril Component Example
var root = document.body
var count = 0
var Hello = {
view: function() {
return m("main", [
m("h1", {
class: "title"
}, "My first app"),
m("button", {
onclick: function() {count++}
}, count + " clicks"),
])
}
}
var Splash = {
view: function() {
return m("a", {
href: "#!/hello"
}, "Enter!")
}
}
m.route(root, "/splash", {
"/splash": Splash,
"/hello": Hello,
})
<script src="https://unpkg.com/mithril"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment