-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
use dioxus::prelude::*;
fn main() {
dioxus::desktop::launch(App);
}
#[derive(Props, PartialEq)]
struct PostProps {
title: &'static str,
content: &'static str,
}
fn Post(cx: Scope<PostProps>) -> Element {
cx.render(rsx!(
style {
[ ".title { font-size: 18px; text-align: center;}",
".content{width:100%;}"]
}
div {
class: "card-content",
h1 {class:"title","{cx.props.title}" },
p {class:"content","{cx.props.content}" }
}
))
}
fn App(cx: Scope) -> Element {
let blogs = vec![
("Hello World", "这是我的第一篇博客"),
("Dioxus 项目", "Dioxus 非常有趣"),
("这是哪里", "这里是 DioxusChina"),
];
let ele = blogs.iter().map(|(title, content)| {
rsx! {
div{
class: "card",
Post {
title:title,
content: content,
}
}
}
});
cx.render(rsx! {
link {
rel: "stylesheet",
href: "https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css"
}
div {
class: "container",
ele
}
})
}
文档中的代码编译报错
error[E0433]: failed to resolve: could not find `desktop` in `dioxus`
--> src\main.rs:3:13
|
3 | dioxus::desktop::launch(App);
| ^^^^^^^ could not find `desktop` in `dioxus`
error[E0599]: the method `into_vnode` exists for array `[&str; 2]`, but its trait bounds were not satisfied
--> src\main.rs:12:15
|
12 | cx.render(rsx!(
| _______________^
13 | | style {
14 | | [ ".title { font-size: 18px; text-align: center;}",
15 | | ".content{width:100%;}"]
... |
21 | | }
22 | | ))
| |_____^ method cannot be called on `[&str; 2]` due to unsatisfied trait bounds
Metadata
Metadata
Assignees
Labels
No labels