带有kotlinx.html的json脚本
使用kotlinx.html构建html页面 很多内容构建起来都没有问题,但是在添加带有id的json脚本标记时遇到了障碍,因此客户端上的代码可以检索json数据 代码应该是什么样的带有kotlinx.html的json脚本,kotlin,kotlinx-html,Kotlin,Kotlinx Html,使用kotlinx.html构建html页面 很多内容构建起来都没有问题,但是在添加带有id的json脚本标记时遇到了障碍,因此客户端上的代码可以检索json数据 代码应该是什么样的 <script id="jsondata" type="application/json"> { "jsondata": "is here" } </script> 但与其他标记不同,script似乎没有id属性。关于如何设置脚本标记的id有什么想法吗?您所需要的就是(带有标记属性的
<script id="jsondata" type="application/json">
{ "jsondata": "is here" }
</script>
但与其他标记不同,script
似乎没有id
属性。关于如何设置脚本标记的id有什么想法吗?您所需要的就是(带有标记属性的可变映射)
将为您提供以下结果:
{“jsondata”:“在这里”}
script(type="application/json"){
+"""{ "jsondata": "is here"}"""
}
script(type = "application/json") {
attributes["id"] = "jsondata"
unsafe { +"""{ "jsondata": "is here" }""" }
}