From e289ddee99fcc3129e65485e32f394c1308bb98b Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 22 Jul 2019 19:43:32 +0200 Subject: [PATCH] feat: scoped slot for link --- examples/basic/app.js | 5 +++++ src/components/link.js | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/examples/basic/app.js b/examples/basic/app.js index e1ae4dede..cced2e29e 100644 --- a/examples/basic/app.js +++ b/examples/basic/app.js @@ -43,6 +43,11 @@ new Vue({
  • /é?t=%ñ
  • /é#%25ñ
  • + +
  • + {{ props.route.path }} (with v-slot). +
  • +
    {{ n }}
    diff --git a/src/components/link.js b/src/components/link.js index d944e8b82..591b31727 100644 --- a/src/components/link.js +++ b/src/components/link.js @@ -83,8 +83,28 @@ export default { on[this.event] = handler } - const data: any = { - class: classes + const data: any = { class: classes } + + console.log({ + scoped: this.$scopedSlots, + slots: this.$slots + }) + const scopedSlot = + !this.$scopedSlots.$hasNormal && + this.$scopedSlots.default && + this.$scopedSlots.default({ + href, + route, + navigate: handler, + isActive: classes[activeClass], + isExactActive: classes[exactActiveClass] + }) + + console.log(scopedSlot) + + if (scopedSlot) { + if (scopedSlot.length > 1 || !scopedSlot.length) throw new Error('no') + return scopedSlot[0] } if (this.tag === 'a') {