custom_assets.rs 649 B

12345678910111213141516171819202122
  1. //! A simple example on how to use assets loading from the filesystem.
  2. //!
  3. //! Dioxus provides the asset!() macro which is a convenient way to load assets from the filesystem.
  4. //! This ensures the asset makes it into the bundle through dependencies and is accessible in environments
  5. //! like web and android where assets are lazily loaded using platform-specific APIs.
  6. use dioxus::prelude::*;
  7. static ASSET_PATH: Asset = asset!("/examples/assets/logo.png");
  8. fn main() {
  9. dioxus::launch(app);
  10. }
  11. fn app() -> Element {
  12. rsx! {
  13. div {
  14. h1 { "This should show an image:" }
  15. img { src: ASSET_PATH }
  16. }
  17. }
  18. }