Created
April 11, 2017 06:18
-
-
Save tivac/cd7c5afda1eeef6412eb7387ed962dbf to your computer and use it in GitHub Desktop.
Mithril Component Example
This file contains hidden or 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
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, | |
}) |
This file contains hidden or 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
<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