Debian Codegraph @

.cargo/vendor/wasm-bindgen/guide/src/examples/dom.md

raw
1 # web-sys: DOM hello world
2
3 [View full source code][code] or [view the compiled example online][online]
4
5 [online]: https://rustwasm.github.io/wasm-bindgen/exbuild/dom/
6 [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/dom
7
8 Using `web-sys` we're able to interact with all the standard web platform
9 methods, including those of the DOM! Here we take a look at a simple "Hello,
10 world!" which manufactures a DOM element in Rust, customizes it, and then
11 appends it to the page.
12
13 ## `Cargo.toml`
14
15 You can see here how we depend on `web-sys` and activate associated features to
16 enable all the various APIs:
17
18 ```toml
19 {{#include ../../../examples/dom/Cargo.toml}}
20 ```
21
22 ## `src/lib.rs`
23
24 ```rust
25 {{#include ../../../examples/dom/src/lib.rs}}
26 ```