pub enum View {
Element(Element),
Text(Text),
Component(ComponentRepr),
CoreComponent(CoreComponent),
Transparent(Transparent),
Suspense(HydrationKey, CoreComponent),
}
Expand description
A leptos view which can be mounted to the DOM.
Variants§
Element(Element)
HTML element node.
Text(Text)
HTML text node.
Component(ComponentRepr)
Custom leptos component.
CoreComponent(CoreComponent)
leptos core-component.
Transparent(Transparent)
Wraps arbitrary data that’s not part of the view but is passed via the view tree.
Suspense(HydrationKey, CoreComponent)
Marks the contents of Suspense component, which can be replaced in streaming SSR.
Implementations§
source§impl View
impl View
sourcepub fn render_to_string(self, _cx: Scope) -> Cow<'static, str>
pub fn render_to_string(self, _cx: Scope) -> Cow<'static, str>
Consumes the node and renders it into an HTML string.
source§impl View
impl View
sourcepub fn as_element(&self) -> Option<&Element>
pub fn as_element(&self) -> Option<&Element>
sourcepub fn as_transparent(&self) -> Option<&Transparent>
pub fn as_transparent(&self) -> Option<&Transparent>
Returns Some
Transparent
if the view is of this type. None
otherwise.
sourcepub fn into_html_element(
self,
cx: Scope
) -> Result<HtmlElement<AnyElement>, View>
pub fn into_html_element(
self,
cx: Scope
) -> Result<HtmlElement<AnyElement>, View>
sourcepub fn on<E>(
self,
event: E,
event_handler: impl FnMut(<E as EventDescriptor>::EventType) + 'static
) -> Viewwhere
E: EventDescriptor + 'static,
pub fn on<E>(
self,
event: E,
event_handler: impl FnMut(<E as EventDescriptor>::EventType) + 'static
) -> Viewwhere
E: EventDescriptor + 'static,
Adds an event listener, analogous to HtmlElement::on
.
This method will attach an event listener to all child
HtmlElement
children.