Code Monkey home page Code Monkey logo

Comments (4)

Scrum avatar Scrum commented on June 16, 2024

@Nincha Hi, sorry for the long answer.

  1. Please note that I use a declarative approach to define the template.
  2. You can try using string template to define a template
  3. maybe it is worth giving up Runtime-only to the side Runtime + Compiler

from vue-2-breadcrumbs.

scottadamsmith avatar scottadamsmith commented on June 16, 2024

Could this be solved with slots? Perhaps a default slot for the root element and then a repeated slot for the items within, providing the scoped data one would need to use an alternative set of components to render their breadcrumbs.

from vue-2-breadcrumbs.

Nincha avatar Nincha commented on June 16, 2024

Sorry I didn't see your answer @Scrum, the last message notified me just now. Thanks for the feedback, I'll try to give a try to your suggestions in a near future. :)

from vue-2-breadcrumbs.

scottadamsmith avatar scottadamsmith commented on June 16, 2024

Alternatively, I was able to use the custom templates with components by writing a render function instead of using the template string. Not ideal, but was able to get past it without a change in the library. I think slots would still be a nice touch for those that would still prefer to compose their template in a traditional single file component.

Here is what I wrote to use the this library with the breadcrumb components from boostrap-vue:

import Vue from "vue";
import VueBreadcrumbs from "vue-2-breadcrumbs";

Vue.use(VueBreadcrumbs, {
  render: function(c) {
    if (this.$breadcrumbs.length) {
      return c( "b-breadcrumb", this.$breadcrumbs.map((crumb, index) => {
          return crumb.meta.breadcrumb
            ? c(
                "b-breadcrumb-item",
                {
                  key: `breadcrumb-item-${index}`,
                  props: {
                    to: { path: this.getPath(crumb) }
                  }
                },
                this.getBreadcrumb(crumb.meta.breadcrumb)
              )
            : null;
        })
      );
    }
  }
});

from vue-2-breadcrumbs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.