4 个版本 (2 个重大更改)

0.3.0 2023年6月30日
0.2.1 2023年6月9日
0.2.0 2023年6月9日
0.1.0 2023年3月27日

20#isomorphic 中排名

Download history 25/week @ 2024-03-16 8/week @ 2024-03-23 38/week @ 2024-03-30 5/week @ 2024-04-06

每月下载量 51

MIT 许可证

19KB
299

leptos_declarative

用于表示控制流和其他有用结构的声明式组件,在 leptos 网页框架中默认不直接提供。

该软件包提供 2 个主要组件

  • 如果
  • 门户

使用方法

有关更多使用示例,请参阅相应组件的文档,但这里有一些示例。

如果

use leptos::*;
use leptos_declarative::prelude::*;

let (a, _) = create_signal(cx, true);
let (b, _) = create_signal(cx, false);

view! { cx,
  <If signal=a>
    <Then>"A is true!"</Then>
    <ElseIf signal=b>"B is true!"</ElseIf>
    <Else>"Both A and B are false!"</Else>
  </If>
};

门户

use leptos::*;
use leptos_declarative::prelude::*;

struct PortalId;

view! { cx,
 <PortalProvider>
   <div>
     <h1>"Portal goes here!"</h1>
     <PortalOutput id=PortalId />
   </div>
   <Portal id=PortalId>
     <p>"I went through the portal!"</p>
   </Portal>
 </PortalProvider>
};

lib.rs:

用于表示控制流和其他有用结构的声明式组件,在 leptos 网页框架中默认不直接提供。

该软件包提供 2 个主要组件

使用方法

有关更多使用示例,请参阅相应组件的文档,但这里有一些示例。

如果

use leptos::*;
use leptos_declarative::prelude::*;

let (a, _) = create_signal(cx, true);
let (b, _) = create_signal(cx, false);

view! { cx,
<If signal=a>
  <Then>"A is true!"</Then>
  <ElseIf signal=b>"B is true!"</ElseIf>
  <Else>"Both A and B are false!"</Else>
</If>
};

门户

use leptos::*;
use leptos_declarative::prelude::*;


struct PortalId;

view! { cx,
  <PortalProvider>
    <div>
      <h1>"Portal goes here!"</h1>
      <PortalOutput id=PortalId />
    </div>

    <PortalInput id=PortalId>
      <p>"I went through the portal!"</p>
    </PortalInput>
  </PortalProvider>
};

依赖项

~18–36MB
~542K SLoC