fix: Toast cfg in ssr mode (#144)

This commit is contained in:
luoxiaozero 2024-03-18 22:00:09 +08:00 committed by GitHub
parent dc1f9842a2
commit a0654a789d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,7 @@ pub struct ToastOptions {
pub fn show_toast(options: ToastOptions) { pub fn show_toast(options: ToastOptions) {
mount_style("toast", include_str!("./toast.css")); mount_style("toast", include_str!("./toast.css"));
cfg_if! { if #[cfg(target_arch = "wasm32")] { cfg_if! { if #[cfg(all(target_arch = "wasm32", any(feature = "csr", feature = "hydrate")))] {
use leptos::{leptos_dom::Mountable, *}; use leptos::{leptos_dom::Mountable, *};
let mount = document().body().expect("body element to exist"); let mount = document().body().expect("body element to exist");
let children = view! { <div class="thaw-toast">{options.message}</div> }; let children = view! { <div class="thaw-toast">{options.message}</div> };