Struct leptos_meta::ScriptProps
source · pub struct ScriptProps {Show 13 fields
pub id: Option<Cow<'static, str>>,
pub async_: Option<Cow<'static, str>>,
pub crossorigin: Option<Cow<'static, str>>,
pub defer: Option<Cow<'static, str>>,
pub fetchpriority: Option<Cow<'static, str>>,
pub integrity: Option<Cow<'static, str>>,
pub nomodule: Option<Cow<'static, str>>,
pub nonce: Option<Cow<'static, str>>,
pub referrerpolicy: Option<Cow<'static, str>>,
pub src: Option<Cow<'static, str>>,
pub type_: Option<Cow<'static, str>>,
pub blocking: Option<Cow<'static, str>>,
pub children: Option<Box<dyn FnOnce(Scope) -> Fragment>>,
}
Expand description
Props for the Script
component.
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
Fields§
§id: Option<Cow<'static, str>>
An ID for the <script>
tag.
async_: Option<Cow<'static, str>>
The async
attribute.
crossorigin: Option<Cow<'static, str>>
The crossorigin
attribute.
defer: Option<Cow<'static, str>>
The defer
attribute.
fetchpriority: Option<Cow<'static, str>>
The fetchpriority
attribute.
integrity: Option<Cow<'static, str>>
The integrity
attribute.
nomodule: Option<Cow<'static, str>>
The nomodule
attribute.
nonce: Option<Cow<'static, str>>
The nonce
attribute.
referrerpolicy: Option<Cow<'static, str>>
The referrerpolicy
attribute.
src: Option<Cow<'static, str>>
The src
attribute.
type_: Option<Cow<'static, str>>
The type
attribute.
blocking: Option<Cow<'static, str>>
The blocking
attribute.
children: Option<Box<dyn FnOnce(Scope) -> Fragment>>
The content of the <script>
tag.
Implementations§
source§impl ScriptProps
impl ScriptProps
sourcepub fn builder(
) -> ScriptPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder( ) -> ScriptPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building ScriptProps
.
On the builder, call .id(...)
(optional), .async_(...)
(optional), .crossorigin(...)
(optional), .defer(...)
(optional), .fetchpriority(...)
(optional), .integrity(...)
(optional), .nomodule(...)
(optional), .nonce(...)
(optional), .referrerpolicy(...)
(optional), .src(...)
(optional), .type_(...)
(optional), .blocking(...)
(optional), .children(...)
(optional) to set the values of the fields.
Finally, call .build()
to create the instance of ScriptProps
.