@sonicgarden/vwrap

Wrapping Vue components with custom elements.
21,585
Install
npm install @sonicgarden/vwrap
Latest Version:1.1.0
Vue:3
Older releases:2
License:MIT
Last Updated:Jul 15, 2022
Links: GitHub  ·  npm
Maintainer: latica.jp

vwrap

Wrapping Vue components with custom elements.

Vue compatibility

Vue Version vwrap Version
v3.x 1.x
v2.x 0.x

Installation

yarn add @sonicgarden/vwrap

Usage

import { vwrap } from '@sonicgarden/vwrap'
import MyComponent from './MyComponent.vue'
import MyComponentWithSlot from './MyComponentWithSlot.vue'

vwrap('my-component', MyComponent)
vwrap('my-async-component', async () => (await import('./MyAsyncComponent.vue')).default)
vwrap('my-component-with-slot', MyComponentWithSlot, { hasSlot: true })

You can then use this element in an HTML file:

<my-component data-props="{\"content\":\"Hello, world!\"}"></my-component>
<my-async-component data-props="{\"content\":\"Hello, world!\"}"></my-async-component>

<my-component-with-slot>
  <template slot="trigger"><button>Click!</button></template>
  <template>
    <div class="alert">Hello, world!</div>
  </template>
</my-component-with-slot>

Refer to the type definitions for more options.

Limitation

  • Attribute changes
  • Slots changes
  • Events trigger
  • ShadowDOM

Related Packages

@sonicgarden/vue-custom-element-rails

vue\-custom\-element wrapper

1,994
@sonicgarden/bs-tooltip-element

Installation

6,756 0

Version History

Version Released License
1.1.0 MIT
1.0.2 MIT
1.0.1 MIT
1.0.0 MIT
0.2.0 MIT