#yew-component #front-end #webasm #web

yew-autoprops

用于为Yew组件自动从参数推导属性结构体的proc-macro

6个版本 (3个重大变更)

0.4.1 2023年12月4日
0.4.0 2023年12月4日
0.3.0 2023年10月30日
0.2.2 2023年5月22日
0.1.0 2023年5月21日

#366WebAssembly

Download history 101/week @ 2024-04-05 143/week @ 2024-04-12 70/week @ 2024-04-19 333/week @ 2024-04-26 74/week @ 2024-05-03 236/week @ 2024-05-10 96/week @ 2024-05-17 82/week @ 2024-05-24 91/week @ 2024-05-31 76/week @ 2024-06-07 107/week @ 2024-06-14 99/week @ 2024-06-21 46/week @ 2024-06-28 116/week @ 2024-07-05 61/week @ 2024-07-12 118/week @ 2024-07-19

350 每月下载量

MIT/Apache

13KB
245

yew-autoprops

Crate Info API Docs

用于为Yew组件自动从参数推导属性结构体的proc-macro

不再需要额外的Props结构体!

示例

use yew_autoprops::autoprops;
use yew::prelude::*;

#[autoprops]
#[function_component]
fn CoolComponent(#[prop_or_default] hidden: bool, smth: &AttrValue) -> Html {
    html! {
        <div class={classes!(hidden.then_some("hidden"))}>
            <p>{ smth }</p>
        </div>
    }
}
use yew_autoprops::autoprops;
use yew::prelude::*;

#[autoprops(CoolComponentProps)]
#[function_component(CoolComponent)]
fn cool_component(#[prop_or_default] hidden: bool, smth: &AttrValue) -> Html {
    html! {
        <div class={classes!(hidden.then_some("hidden"))}>
            <p>{ smth }</p>
        </div>
    }
}

依赖关系

~325–790KB
~19K SLoC