vue-mount-component-to-dom
v0.0.1
Published
mount component to dom for vue component module. 挂载组件到dom,并注册到 Vue.prototype
Downloads
2
Maintainers
Readme
vue-mount-component-to-dom
mount vue component to dom
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