mountComponent
interface MountOptions {
/**
* Element to mount component under. Default `<body>`.
*/
attachTo?: string | Element;
/**
* Attach as first child. Default `false`.
*/
attachFirst?: boolean;
}
function mountComponent(
callingInstance: MaybeWithFKUIContext,
Component: MaybeComponent,
options?: Record<string, unknown> & MountOptions,
): App<Element>;
Mount a VUE component using API. The component will be mounted as a child of the target element and not onto the element itself.
Usage
/* mount component */
const targetElement = document.querySelector("body")!;
const app = mountComponent(this, MyComponent, {
attachTo: targetElement,
});
/* do fancy stuff */
/* cleanup */
app.unmount();
Passing props and listeners
Props and listeners can be passed in the options object:
mountComponent(this, MyComponent, {
attachTo: targetElement,
/* props */
foo: "bar",
/* listeners */
onSubmit(): void {
/* do something */
},
});