dioxus/examples/custom_assets.rs

21 lines
448 B
Rust
Raw Normal View History

2022-01-27 21:36:17 +00:00
use dioxus::prelude::*;
2024-01-18 20:36:42 +00:00
#[cfg(not(feature = "collect-assets"))]
static ASSET_PATH: &str = "examples/assets/logo.png";
#[cfg(feature = "collect-assets")]
static ASSET_PATH: &str = manganis::mg!(image("examples/assets/logo.png").format(ImageType::Avif));
2022-01-27 21:36:17 +00:00
fn main() {
2024-01-20 08:11:55 +00:00
launch(app);
2022-01-27 21:36:17 +00:00
}
fn app() -> Element {
2024-01-16 19:18:46 +00:00
rsx! {
2022-01-27 21:36:17 +00:00
div {
2024-01-18 20:36:42 +00:00
p { "This should show an image:" }
img { src: ASSET_PATH.to_string() }
2022-01-27 21:36:17 +00:00
}
2024-01-14 05:12:21 +00:00
}
2022-01-27 21:36:17 +00:00
}