I am building a simple web app with Rust and I am trying to display an image to the website. But I can't add that image.
I am using Rust with a framework called Yew and with a tool Trunk.
I have successfully linked the .scss file to my website with Trunk. As they described in their documentation.
index.html
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Yew Development</title>
<link data-trunk="" rel="scss" href="main.scss"> <!-- Successfull linked to this file -->
</head>
<body></body>
</html>
The .scss file does its work successfully.
But how can I display an image with Rust file with the html!
macro?
main.rs
use yew::prelude::*;
fn main() {
yew::start_app::<App>();
}
#[function_component(App)]
fn app() -> Html {
html! {
<>
<h1> {"Hello world!"}</h1>
<link data-trunk="true" rel="copy-file" href="img/rust.png"/> // doesn't work
<img data-trunk="true" src="img/rust.png" alt="rust image"/> // doesn't work
<img src="img/rust.png" alt="rust image"/> // doesn't work
</>
}
}
Trunk's docs about how to add image.
But the doc wasn't helpful for me.