vue-mount-component-to-dom
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

vue-mount-component-to-dom

  1. mount vue component to dom

  2. add component instance to Vue.prototype, you can call functions directly in vue

Usage

mountComponent(
  _vue: Vue | VueConstructor<Vue>,
  protoName: string,
  vueCompConf: VueConstructor<Vue>,
  el: HTMLElement = document.body   // optional. default is document.body
)

Demo

/**
 * file: main.js
 */
import Vue from "vue"
import { Toast } from "@/src/components/Toast/index.vue"
 
import mountComponent from "vue-mount-component-to-dom"
mountComponent(Vue, "$Toast", Toast)
 
/**
 * file: somePage.vue
 */
export default class SomePage extends Vue {
  showTip() {
    // you can call `this.$Toast` directly
    this.$Toast.show()
  }
}

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    1

Package Sidebar

Install

npm i vue-mount-component-to-dom

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

4.75 kB

Total Files

6

Last publish

Collaborators

  • microj