新手模板

trunk

  • 最简模板 - 通过 Trunk 构建的小型应用程序,可以帮助快速您入门。

wasm-pack

与其他工具不同, wasm-pack强制您使用lib而不是bin crate,并且程序的入口需要用#[wasm_bindgen(start)]属性进行标注。

你的 Cargo.toml 同样应该指明你的工程的 crate 类型是 “cdylib” 。

  1. [package]
  2. name = "yew-app"
  3. version = "0.1.0"
  4. authors = ["Yew App Developer <[email protected]>"]
  5. edition = "2018"
  6. [lib]
  7. # You should include "rlib" (the default crate type) otherwise your crate can't be used as a Rust library
  8. # which, among other things, breaks unit testing
  9. crate-type = ["rlib", "cdylib"]
  10. [dependencies]
  11. # for web_sys
  12. yew = "0.17"
  13. # or for stdweb
  14. # yew = { version = "0.17", package = "yew-stdweb" }
  15. wasm-bindgen = "0.2"

其他模板