Skip to main content

mount

Function mount 

Source
pub fn mount<F>(selector: &str, render_fn: F)
where F: FnOnce() -> VirtualNode,
Expand description

Mounts the given virtual DOM tree to a specific element matched by a CSS selector.

Supported selector syntax:

  • "#id" — select by element ID
  • ".class" — select by class name (uses the first match)
  • "tag" — select by tag name (uses the first match)

§Arguments

  • &str - A CSS selector string to locate the target element.
  • FnOnce() -> VirtualNode + 'static - A closure that returns the virtual DOM tree to render.

§Panics

Panics if no global window or document exists, or if the selector does not match any element.