npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-router-multi-view

v0.1.0

Published

router-view meet v-show meet keep-alive

Downloads

115

Readme

Sponsors

Silver

Bronze

About

Replace <router-view/> with <router-multi-view/> to keep the DOM of the deactivated route alive.

Useful Links

Installation

Npm

npm install --save vue-router-multi-view

Install the plugin into Vue:

import Vue from 'vue'
import VueRouterMultiView from 'vue-router-multi-view'

Vue.use(VueRouterMultiView)

Or use the directives and components directly:

import Vue from 'vue'
import { VueRouterMultiView } from 'vue-router-multi-view'

Vue.directive('router-multi-view', VueRouterMultiView)

Browser

Include vue-router-multi-view in the page.

<script src="https://unpkg.com/vue-router-multi-view"></script>

If Vue is detected in the Page, the plugin is installed automatically.

Manually install the plugin into Vue:

Vue.use(VueRouterMultiView)

Usage

Replace <router-view/> with <router-multi-view/> and replace the name prop by the viewName prop (this is to prevent potential conflicts with <transition-group>).

:warning: Contrary to <router-view/>, <router-multi-view/> will need to wrap the content with an element or component (default: <div>).

If you were using the keep-alive component, you need to remove it. So if you had:

<keep-alive>
  <router-view />
</keep-alive>

It should be replaced by:

<router-multi-view />

<router-multi-view /> already includes keep-alive and will trigger the activated and deactivated hooks on the children components.

:warning: It is recommended to use props for the routes.

Example:

<template>
  <div id="app">
    <router-multi-view view-name="header" />
    <router-multi-view />
    <router-multi-view view-name="footer" />
  </div>
</template>

Example of rendered HTML:

<div>
  <div class="page" data-route-path="/c" style="display: none;">
      <h1>Nested routes</h1>
      <nav><a href="/c/" class="">Nested 1</a> <a href="/c/nested2" class="">Nested 2</a></nav>
      <!---->
  </div>
  <div class="page" data-route-path="/b2/:id" data-route-name="page-b2" style="display: none;">
      <h1>Route with props params</h1>

      bar
  </div>
  <div class="page" data-route-path="" data-route-name="page-a" data-is-active="true">
      <h1>Simple page</h1>
  </div>
</div>

You can change the element or component used to wrap the routes with the morph prop:

<router-multi-view morph="section" class="my-section" />

To use transition, you need to use the viewName prop to set the name of the view, to prevent a conflict with the name prop for the transition:

<router-multi-view
  class="wrapper"

  view-name="default"
  morph="transition-group"

  tag="div"
  name="fade"
/>

Here view-name and morph are <router-multi-view/> props, while tag and name are <transition-group> props.