Function leptos_meta::Script

source ·
pub fn Script(cx: Scope, props: ScriptProps) -> impl IntoView
Expand description

Injects an HTMLScriptElement into the document head, accepting any of the valid attributes for that tag.

use leptos::*;
use leptos_meta::*;
#[component]
fn MyApp(cx: Scope) -> impl IntoView {
    provide_meta_context(cx);
    view! { cx,
      <main>
        <Script>
          "console.log('Hello, world!');"
        </Script>
      </main>
    }
}

Required Props

  • cx: [Scope]

Optional Props

  • id: [impl Into<Cow<'static, str>>](Cow<’static, str>)
    • An ID for the <script> tag.
  • async_: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • crossorigin: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • defer: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • fetchpriority: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • integrity: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • nomodule: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • nonce: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • referrerpolicy: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • src: [impl Into<Cow<'static, str>>](Cow<’static, str>)
    • The src attribute.
  • type_: [impl Into<Cow<'static, str>>](Cow<’static, str>)
    • The type attribute.
  • blocking: [impl Into<Cow<'static, str>>](Cow<’static, str>)
  • children: [Box<dyn FnOnce(Scope) -> Fragment>]
    • The content of the <script> tag.