LaravelVueJs

Implements simple breadcrumb functionality with vue-router



vue-breadcrumbs

Vue breadcrumbs builds on the official vue-router package to provide simple breadcrumbs. This package is backwards compatible to support both Vue 1.x and Vue 2.x.

Live Demo

https://samturrell.github.io/vue-breadcrumbs/example

Installation

http://vuejsexamples.com/dist/vue-breadcrumbs.min.js  
Vue.use(VueBreadcrumbs)  

or via npm:

$ npm install vue-breadcrumbs
import VueBreadcrumbs from 'vue-breadcrumbs'

Vue.use(VueBreadcrumbs)  

Define the matching breadcrumb text in your routes.

An options object can also be passed into the plugin to specify your own template and rendering methods if desired. For example:

Vue.use(VueBreadcrumbs, {  
  template: '<nav class="breadcrumb" v-if="$breadcrumbs.length"> ' +
    '<router-link class="breadcrumb-item" v-for="(crumb, key) in $breadcrumbs" :to="linkProp(crumb)" :key="key">{{ crumb | crumbText }}</router-link> ' +
    '</nav>'
});

Usage

Vue 1.x

Use the breadcrumb: property of a route or subRoute, e.g.:

router.map({  
  '/': {
    component: Page,
    breadcrumb: 'Home Page',
    subRoutes: {
      '/foo': {
        component: Foo,
        breadcrumb: 'Foo Page'
      },
      '/bar': {
        component: Bar,
        breadcrumb: 'Bar Page'
      }
    }
  }
})

Vue 2.x

Use the meta.breadcrumb: property of a route or child route, e.g.:

new VueRouter({  
  routes: [
    {
      path: '/', 
      component: Page,
      meta: {
        breadcrumb: 'Home Page',
      },
      children: [
        {
          path: '/foo', 
          component: Foo,
          meta: {
            breadcrumb: 'Foo Page'  
          }
        },
        {
          path: '/bar', 
          component: Bar,
          meta: {
            breadcrumb: 'Bar Page'
          }
        }
      ]
    }
  ]
})

GitHub




Source link

★ READ ALSO ★  Mobile-friendly Image Viewer For Vue.js

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close