0

kotlinx.html 库 DSL 编写 HTML 和 JavaScript 代码

neo created at6 years ago view count: 3021

地址:https://github.com/Kotlin/kotlinx.html

示例:

window.setInterval({
    val myDiv = document.create.div("panel") {
        p { 
            +"Here is "
            a("http://kotlinlang.org") { +"official Kotlin site" } 
        }
    }

    document.getElementById("container")!!.appendChild(myDiv)

    document.getElementById("container")!!.append {
        div {
            +"added it"
        }
    }
}, 1000L)

在Web开发中的模板应用。使用 kotlinx.html DSL 编写类型安全模板或简单地使用 Kotlin 多 String 字符串插值。

https://github.com/sdeleuze/kotlin-script-templating

report
回复

Recent search keywords