A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
For API documentation, see: API Docs
# use pnpm
$ pnpm install vue-mount-plugin
# use npm
$ npm install vue-mount-plugin --save
# use yarn
$ yarn add vue-mount-plugin
<template>
<div></div>
</template>
<script setup>
import { getCurrentInstance } from 'vue'
import Mount from 'vue-mount-plugin'
import DemoVue from './demo.vue'
const { proxy } = getCurrentInstance()
const instance = new Mount(DemoVue, { parent: proxy.$root })
// mount to the end of document.body
instance.mount()
// destroy
instance.destroy()
</script>
<template>
<div></div>
</template>
<script>
import { getCurrentInstance } from 'vue'
import Mount from 'vue-mount-plugin'
import DemoVue from './demo.vue'
export default {
setup() {
const { proxy } = getCurrentInstance()
const instance = new Mount(DemoVue, { parent: proxy.$root })
// mount to the end of document.body
instance.mount()
// destroy
instance.destroy()
}
}
</script>
Add
@vue/composition-api
to theproject.json
dependencies and run install.
{
"dependencies": {
"@vue/composition-api": "latest"
}
}
<template>
<div></div>
</template>
<script>
import { getCurrentInstance } from '@vue/composition-api'
import Mount from 'vue-mount-plugin'
import DemoVue from './demo.vue'
export default {
setup() {
const { proxy } = getCurrentInstance()
const instance = new Mount(DemoVue, { parent: proxy.$root })
// mount to the end of document.body
instance.mount()
// destroy
instance.destroy()
}
}
</script>
Please open an issue here.