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