UNPKG

vue2-breadcrumbs

Version:

Breadcrumbs for vue.js fork from samturrell/vue-breadcrumbs

38 lines (32 loc) 1.2 kB
/*! * vue-breadcrumbs v0.3.1 * (c) 2016 Sam Turrell * Released under the MIT License. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.VueBreadcrumbs = factory(); }(this, function () { 'use strict'; function plugin(Vue) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; Object.defineProperties(Vue.prototype, { $breadcrumbs: { get: function get() { var crumbs = []; for (var i = 0; i < this.$route.matched.length; i++) { if (this.$route.matched[i].meta && this.$route.matched[i].meta.breadcrumb) { crumbs.push(this.$route.matched[i]); } } return crumbs; } } }); Vue.component('breadcrumbs', { template: '<nav class="breadcrumbs" v-if="$breadcrumbs.length"> <ul> <li v-for="(crumb, i) in $breadcrumbs"> <router-link :to=" { path: crumb.path }">{{ crumb.meta.breadcrumb }}</router-link> </li> </ul> </nav>' }); } plugin.version = '0.3.1'; return plugin; }));