【发布时间】:2022-02-12 05:35:29
【问题描述】:
CSS 无法通过 maud 与 actix-web 的链接 rel 属性工作。我在哪里犯了错误?
我认为我写链接rel属性的位置是正确的。
main.rs
use actix_files as fs;
use actix_web::{get, App, HttpServer, Result as AwResult};
use maud::{html, Markup};
#[get("/")]
async fn index() -> AwResult<Markup> {
Ok(html! {
head{
link rel="stylesheet" href="/static/style.css"{};
}
title{"Help me"}
p {"Blue text should be shown."}
})
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(fs::Files::new("/static", ".").show_files_listing())
.service(index)
})
.bind("0.0.0.0:80")?
.run()
.await?;
Ok(())
}
style.css
p {
color: blue;
font-size: 50px;
}
【问题讨论】: