JSFiddle - React, Tailwind, and code Playground
by Nadeesh Peiris
HTML
<script src="//unpkg.com/mithril/mithril.js"></script>
CSS
main {
color: white;
border: 1px solid black;
}
.title {
background-color: red;
}
JavaScript
var root = document.body
// 1 _________________________________________________________________________
m.render(root, "Hello world")
// 2 _________________________________________________________________________
//m.render(root, m("h1", "My first app"))
// 3 _________________________________________________________________________
//m.render(root, m("h1", {class: "title"}, "My first app"))
// 4 _________________________________________________________________________
/*
m.render(root, [
m("h1", {class: "title"}, "My first app"),
m("button", "A button"),
])
*/
// 5 _________________________________________________________________________
/*
m.render(root, m("main", [
m("h1", {class: "title"}, "My first app"),
m("button", "A button"),
]))
*/
// 6 _________________________________________________________________________
/*
var Hello = {
view: function() {
return m("main", [
m("h1", {class: "title"}, "My first app"),
m("button", "A button"),
])
}
}
m.mount(root, Hello)
*/
// 7 _________________________________________________________________________
/*
var count = 0 // added a variable
var Hello = {
view: function() {
return m("main", [
m("h1", {class: "title"}, "My first app"),
// changed the next line
m("button", {onclick: function() {count++}}, count + " clicks"),
])
}
}
m.mount(root, Hello)
*/
// 8 _________________________________________________________________________
/*
var Splash = {
view: function() {
return m("a", {href: "#!/hello"}, "Enter!")
}
}
m.route(root, "/splash", {
"/splash": Splash,
"/hello": Hello,
})
*/
// 9 _________________________________________________________________________
/*
var count = 0
var increment = function() {
m.request({
method: "PUT",
url: "//rem-rest-api.herokuapp.com/api/tutorial/1",
data: {count: count + 1},
withCredentials:...