6 个版本 (破坏性)
0.4.0 | 2021 年 3 月 31 日 |
---|---|
0.3.0 | 2020 年 11 月 26 日 |
0.2.1 | 2020 年 4 月 15 日 |
0.1.0 | 2019 年 11 月 25 日 |
0.0.0 | 2019 年 9 月 7 日 |
#1682 in 网页编程
每月 2,022 次下载
在 25 个包中使用了 (直接使用 2 个)
450KB
10K SLoC
iced_web
iced_web
使用 iced_core
并在顶部构建一个 WebAssembly 运行时。它通过引入一个可以用于生成 VDOM 节点的 Widget
特性来实现这一点。
该包目前是一个 非常实验性的、简单的 dodrio
抽象层。
安装
在您的 Cargo.toml
中添加 iced_web
依赖项
iced_web = "0.4"
Iced 开发迅速,master
分支可能会包含破坏性更改!如果您想了解特定版本,请查看 版本列表。
使用
当前的构建过程有些复杂,因为 wasm-pack
目前不支持 构建二进制包。
因此,我们使用 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
注意:请注意,Iced 仍处于早期探索阶段,大部分工作需要在生态系统的本地端进行。在此阶段,能够批量处理工作而无需不断跳转非常重要。因此,目前不需要在 master
分支中始终包含跨平台 API。如果您在构建示例时遇到问题并想帮忙,这可能是一个开始贡献的好方法!
示例编译完成后,我们需要创建一个 .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 服务器提供它,并用浏览器访问它。
依赖项
~11MB
~244K SLoC