mount-vue-component

a tiny utility to programatically create and mount Vue 3 components - e.g. a Vue.extend replacement
67,845 109
Install
npm install mount-vue-component
Latest Version:0.10.2
Vue:3
License:MIT
Last Updated:Aug 30, 2024
Links: GitHub  ·  npm
Maintainer: pearofducks

mount-vue-component

install

yarn add mount-vue-component

use

import { mount } from 'mount-vue-component'
import { h } from 'vue'

const comp = {
  props: ['name'],
  setup: (props) => () => h('h1', `Hello, ${props.name}!`),
  unmounted() { console.log("Bye") },
  mounted() { console.log("Hi") }
}
const { vNode, destroy, el } = mount(comp, { props: { name: 'world' } })

api

mount(component, { props, children, element, app })
  • component: required, the component to be created/mounted
  • props: props to be passed onto the component, this can include HTML attributes like id or class
  • children: components to be rendered as children of component
  • element: if specified, the element to mount the component into, if not specified, a div will be created
  • app: the Vue app instance from createApp, if provided will be bound to the component's appContext
returns { vNode, destroy, el }
  • vNode: the instance of the component provided
  • destroy: a function that will unmount and destroy the component
  • el: will provide the HTML element the component is mounted into

Related Packages

@bryntum/schedulerpro-vue-3-thin

Vue 3 wrappers for Bryntum Scheduler Pro JavaScript component

26,973
vue-3-infinite-scroll-directive-plugin

Vue 3 plugin to help implementing an infinite scroll

25,994
@bryntum/gantt-vue-3-thin

Vue 3 wrappers for Bryntum Gantt JavaScript component

16,091
@bryntum/schedulerpro-vue-3

Vue 3 wrappers for Bryntum Scheduler Pro JavaScript component

4,616
@bryntum/gantt-vue-3

Vue 3 wrappers for Bryntum Gantt JavaScript component

4,373

Version History

Version Released License
0.10.2 MIT
0.10.1 MIT
0.10.0 MIT
0.9.5 MIT
0.9.4 MIT