private fun renderBooks(data: Array<String>) {
val books = document.create.div("books") {
table("table table-hover") {
thead {
tr {
th {
+"ID"
}
th {
+"Name"
}
}
}
tbody {
data.forEachIndexed { index, s ->
tr {
td {
+"$index"
}
td {
+s
}
}
}
}
}
}
document.getElementById("books")?.appendChild(books)
}
完整实例代码参考:https://github.com/Jason-Chen-2017/kotlin-js-gradle-demo
kotlinx.html参考文档:https://github.com/Kotlin/kotlinx.html