Unable to use #[cfg(target_os = "windows")] into a #[function_component] function #3049
-
Problem Steps To Reproduce #[function_component(App)]
pub fn app() -> Html {
} You can't use any cfg macro or any conditional compiling macro. #[cfg(target_os = "windows")]
html! {
<section class="sidebar leftbar">
<h2>{"On Windows"}</h2>
</section>
}
#[cfg(not(target_os = "windows"))]
html! {
<section class="sidebar leftbar">
<h2>{"Not on Windows"}</h2>
</section>
} The #[function_component(App)] or into functions that are called from a component function. Expected behavior Environment:
Questionnaire
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
target_os
checks the compilation target. The Yew app is compiled to WASM (wasm32-unknown-unknown
). You'll have to use a Tauri API to check the current platform at runtime and act accordingly