vue-portal

teleports the content to another location in the dom
11,764 4
Install
npm install vue-portal
Latest Version:1.0.0
Vue:1
License:MIT
Last Updated:Mar 24, 2017
Links: GitHub  ·  npm
Maintainer: linusborg

vue-portal

teleports the content to another location in the dom. Similar to vue-transfer-dom and vue-move-dom, but as a component instead of a directive.

Demo

Install

npm install --save-dev vue-portal

or include build/bundle.js.

Usage

# in your component
components:
  "portal": require("vue-portal")
# or, when using bundle.js
components:
  "portal": window.vueComps.portal
<portal>
  <span>Will be appended to body</span>
</portal>
<portal target="#somewhere">
  <span>Will be appended to element with ID somewhere</span>
</portal>

For examples see dev/.

Props
Name type default description
target String or Element - where the content will be appended. Defaults to document.body. Uses document.querySelector to convert a String to Element.

Behavior

Works with v-if but not v-show on <portal>.

<portal v-if="active">
  <span>Will be appended to body</span>
</portal>
<portal>
  <span v-show="active">Will be appended to element with ID somewhere</span>
</portal>

target prop can be dynamic.

Development

Clone repository.

npm install
npm run dev

Browse to http://localhost:8080/.

License

Copyright (c) 2016 Paul Pflugradt Licensed under the MIT license.

Related Packages

vue3-portal

Portal for Vue 3

12,906 7
adm-portal

后台管理门户

3,337 1
seok-portal

login with poatal, sso

2,575 3
peacock-user-ui

A HTML SPA user portal for view open data datasets

3,134 4
vue-window-portal

Vue component to render content in a new window

2,070 7

Version History

Version Released Vue License
1.0.0 ^1.0.26 MIT