vue-simple-portal
Version:
Simple portal component for Vue.js
71 lines (47 loc) • 1.62 kB
Markdown
# vue-simple-portal
[](https://npmjs.com/package/vue-simple-portal) [](https://npmjs.com/package/vue-simple-portal) [](https://circleci.com/gh/EGOIST/vue-simple-portal/tree/master)
Simple portal component which allows to mount component anywhere.
Just like [portal-vue](https://github.com/LinusBorg/portal-vue/) but does less.
## Install
```bash
yarn add vue-simple-portal
```
CDN: [UNPKG](https://unpkg.com/vue-simple-portal/) | [jsDelivr](https://cdn.jsdelivr.net/npm/vue-simple-portal/) (available as `window.SimplePortal`)
## Usage
Given an html file:
```html
<!-- where your app is mounted -->
<div id="app"></div>
<!-- where the portal targets are mounted -->
<div id="target"></div>
```
And your component:
```vue
<template>
<simple-portal target="target">
<h1>haha</h1>
<h2>it just works<h1>
<p>we'll appear in #target element!</p>
</simple-portal>
</template>
<script>
import SimplePortal from 'vue-simple-portal'
export default {
components: {
SimplePortal
}
}
</script>
```
## Props
### target
Type: `string`<br>
Required: `true`
The id of target HTML element.
### componentName
Type: `string`<br>
Default: `portal-target`
The component name for the portal target component.
It's recommended to set a custom name if you used this component for multiple times.
## License
MIT © [EGOIST](https://github.com/EGOIST)