List icon 目录

概述

JxBrowser 8.0.0 版本不仅增强了对 Kotlin 和 Compose 的支持,同时还引入了一些重大变更。本指南将向您展示如何将基于 JxBrowser 7.x.x 版本编写的应用程序代码更新为与 8.x.x 版本兼容。

JxBrowser 8 目前处于预览阶段。请查看发展规划以获取详细信息。

元素属性

我们将带有属性的操作从 Element 提取到类似映射的 ElementAttributes 中。以下是修改处理属性代码的方法。

获取属性值

在 JxBrowser 7 中:

String value = element.attributeValue("src");
val value : String = element.attributeValue("src")

在 JxBrowser 8 中:

String value = element.attributes.get("src");
val value : String = element.attributes["src"]

写入属性值

在 JxBrowser 7 中:

element.putAttribute("src", "https://example.com/image.png");
element.putAttribute("src", "https://example.com/image.png")

在 JxBrowser 8 中:

element.attributes.put("src", "https://example.com/image.png");
element.attributes["src"] = "https://example.com/image.png"

移除属性

在 JxBrowser 7 中:

element.removeAttribute("src");
element.removeAttribute("src")

在 JxBrowser 8 中:

element.attributes.remove("src");
element.attributes.remove("src")

移除指定的属性

在 JxBrowser 7 中:

boolean exists = element.hasAttribute("src");
val exists : Boolean = element.hasAttribute("src")

在 JxBrowser 8 中:

boolean exists = element.attributes.contains("src");
val exists : Boolean = element.attributes.contains("src")

获取属性映射

在 JxBrowser 7 中:

Map<String, String> attributes = element.attributes();
val attributes : Map<String, String> = element.attributes()

在 JxBrowser 8 中:

Map<String, String> attributes = element.attributes.asMap();
val attributes : Map<String, String> = element.attributes.asMap()

获取属性节点的映射

在 JxBrowser 7 中:

List<Attribute> attributes = element.attributeNodes();
val attributes : List<Attribute> = element.attributeNodes()

在 JxBrowser 8 中:

List<Attribute> attributes = element.attributes.asNodes();
val attributes : List<Attribute> = element.attributes.asNodes()

获取帮助

如果您在本指南中未找到答案,并且需要迁移方面的帮助,请联系我们。我们将很乐意为您提供帮助。

Go top