← 文章 / 未分类
docs 2小时前 · 2026-09-01 10:32:01 · 1 阅读

冰镇网络

一个面向 DOM 的 Iced Web 运行时。

iced_web 基于 iced_core 构建 WebAssembly 运行时,并引入了一个用于生成 VDOM 节点的 Widget trait。

目前,这个 crate 只是对 dodrio 的一个非常实验性且简单的抽象层。

§用法

目前的构建流程稍显繁琐,因为 wasm-pack 暂不支持构建二进制 crate

因此,我们改用 wasm32-unknown-unknown 目标进行构建,再通过 wasm-bindgen CLI 生成相应的绑定。

例如,假设我们要构建 tour 示例

cd examples
cargo build --package tour --target wasm32-unknown-unknown
wasm-bindgen ../target/wasm32-unknown-unknown/debug/tour.wasm --out-dir tour --web

接下来,创建一个 .html 文件来加载应用:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Tour - Iced</title>
  </head>
  <body>
    <script type="module">
      import init from "./tour/tour.js";

      init('./tour/tour_bg.wasm');
    </script>
  </body>
</html>

最后,使用 HTTP 服务器提供该文件,然后通过浏览器访问。

重新导出§

pub use css::Css;pub use subscription::Subscription;pub use executor::Executor;pub use dodrio;pub use iced_futures::futures;pub use widget::*;

模块§

css设置 widget 的样式。executor选择用于驱动运行时的 executor。keyboard复用基础键盘类型。mouse复用基础鼠标类型。subscription监听应用中的外部事件。widget使用内置 widget,或创建自定义 widget。

结构体§

Bus消息发布器。Clipboard用于在应用内部及应用之间短期存储和传输数据的缓冲区。ColorsRGB 色彩空间中的颜色。Command异步操作的集合。Element通用的 WidgetHasher用于比较 subscription 的哈希器。Point二维点。Rectangle矩形。Size二维空间的大小。Vector二维向量。

枚举§

Align容器在某一轴上的对齐方式。Background元素的背景。Font字体。HorizontalAlignment某个资源的水平对齐方式。Length在特定维度上填充空间的策略。VerticalAlignment某个资源的垂直对齐方式。

特征§

Application交互式 Web 应用。
原始来源: docs

评论 (0)