dioxus/examples/custom_assets.rs

21 lines
448 B
Rust
Raw Normal View History

2022-01-27 16:36:17 -05:00
use dioxus::prelude::*;
2024-01-18 12:36:42 -08: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 16:36:17 -05:00
fn main() {
2024-01-20 00:11:55 -08:00
launch(app);
2022-01-27 16:36:17 -05:00
}
fn app() -> Element {
2024-01-16 13:18:46 -06:00
rsx! {
2022-01-27 16:36:17 -05:00
div {
2024-01-18 12:36:42 -08:00
p { "This should show an image:" }
img { src: ASSET_PATH.to_string() }
2022-01-27 16:36:17 -05:00
}
2024-01-13 21:12:21 -08:00
}
2022-01-27 16:36:17 -05:00
}