Navigation in Vue Breadcrumb component

16 Mar 20236 minutes to read

The breadcrumb item navigates to the path while clicking the item. To enable navigation, url property was bound to the items.

URL

In the Breadcrumb component, the item represents the url. The breadcrumb items can be provided with either relative or absolute URL.

Relative URL

The breadcrumb items with relative URL contain only the path but do not locate the path or server. The following example represents the breadcrumb items with relative url.

<template>
<div>
<ejs-breadcrumb :enableNavigation='false'>
  <e-breadcrumb-items>
    <e-breadcrumb-item text= 'Home' url= './breadcrumb'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Breadcrumb' url= './breadcrumb'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Default' url= './breadcrumb/default'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Icons' url= './breadcrumb/icons'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Navigations' url= './breadcrumb/navigations'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Overflow' url= './breadcrumb/overflow'></e-breadcrumb-item>
  </e-breadcrumb-items>
</ejs-breadcrumb>
</div>
</template>

<script>
import Vue from 'vue';
import { BreadcrumbPlugin } from "@syncfusion/ej2-vue-navigations";

Vue.use(BreadcrumbPlugin);

export default {
  data: function() {
        return {};
  }
}
</script>

<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";

body {
    margin-top: 100px;
    text-align: center;
}
</style>

Absolute URL

The breadcrumb items with Absolute URL contain the path and locate to the resource if the absolute url is bound to the breadcrumb item. The following example represents the breadcrumb items with absolute url.

<template>
<div>
<ejs-breadcrumb :enableNavigation='false'>
  <e-breadcrumb-items>
    <e-breadcrumb-item text= 'Home' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/introduction'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Getting' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/getting-started'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Icons' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/icons'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Navigation' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/navigation'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Overflow' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/overflow'></e-breadcrumb-item>
  </e-breadcrumb-items>
</ejs-breadcrumb>
</div>
</template>

<script>
import Vue from 'vue';
import { BreadcrumbPlugin } from "@syncfusion/ej2-vue-navigations";

Vue.use(BreadcrumbPlugin);

export default {
  data: function() {
        return {};
  }
}
</script>

<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";

body {
    margin-top: 100px;
    text-align: center;
}
</style>

Enable navigation for last Breadcrumb item

The feature enables the last item of the Breadcrumb component by setting the enableActiveItemNavigation property to true. In the following example, the last item of the Breadcrumb was enabled.

<template>
<div>
<ejs-breadcrumb :enableNavigation='false' enableActiveItemNavigation='true'>
  <e-breadcrumb-items>
    <e-breadcrumb-item text= 'Home' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/introduction'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Getting' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/getting-started'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Icons' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/icons'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Navigation' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/navigation'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Overflow' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/overflow'></e-breadcrumb-item>
  </e-breadcrumb-items>
</ejs-breadcrumb>
</div>
</template>

<script>
import Vue from 'vue';
import { BreadcrumbPlugin } from "@syncfusion/ej2-vue-navigations";

Vue.use(BreadcrumbPlugin);

export default {
  data: function() {
        return {};
  }
}
</script>

<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";

body {
    margin-top: 100px;
    text-align: center;
}
</style>

Open URL in new page or tab

To open the breadcrumb item in a new page or tab, set the target property of the required item url to blank in the Breadcrumb component. In the following example, the target property of items url was set to blank by using the beforeItemRender event which locates to the path in the new tab.

<template>
<div>
<ejs-breadcrumb :beforeItemRender="beforeItemRenderHandler">
  <e-breadcrumb-items>
    <e-breadcrumb-item text= 'Home' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/introduction'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Getting' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/getting-started'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Icons' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/icons'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Navigation' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/navigation'></e-breadcrumb-item>
    <e-breadcrumb-item text= 'Overflow' url= 'https://ej2.syncfusion.com/documentation/breadcrumb/overflow'></e-breadcrumb-item>
  </e-breadcrumb-items>
</ejs-breadcrumb>
</div>
</template>

<script>
import Vue from 'vue';
import { BreadcrumbPlugin } from "@syncfusion/ej2-vue-navigations";

Vue.use(BreadcrumbPlugin);

export default {
  data: function() {
        return {};
  },
  methods: {
    beforeItemRenderHandler: function(args) {
      if (args.element.children[0]) {
        args.element.children[0].target = "_blank";
      }
    }
  }
}
</script>

<style>
@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";

body {
    margin-top: 100px;
    text-align: center;
}
</style>