Function leptos_meta::Script

source ·
pub fn Script(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() -> impl IntoView {
    provide_meta_context();

    view! {
      <main>
        <Script>
          "console.log('Hello, world!');"
        </Script>
      </main>
    }
}

§Optional Props

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