UNPKG

vue2-breadcrumbs

Version:

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

32 lines (27 loc) 910 B
/*! * vue-breadcrumbs v0.3.1 * (c) 2016 Sam Turrell * Released under the MIT License. */ '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'; module.exports = plugin;