createReusableTemplate for use as a component named slot template #9401
Unanswered
RickKukiela
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
HI!
I have an app I'm working on where I'm using PrimeFaces (PrimeVue) for my front end component UI (I know this is not their forum, please bear with me). For my main app layout I'm using several copies of the
<Menubar>
Component (docs link). If you peep the documentation, you will see there is a template slot named #item which you would supply within the body of the component to dictate how the menu items are rendered.Since I have 3 or 4 different menus on the page but have the exact same #item slot template code for all of them, I would prefer to write the
<template #item="{}">
code a single time, and then use it for the #item slot for each instance of<Menubar>
on my page.I tried following the instructions at https://vueuse.org/core/createReusableTemplate/ to create a template that I could use for this but something doesn't line up and the
<Menubar>
component acts as if I did not pass a<template #item>
at all (default render).I also tried making my own "component" that mimics the slot props and tried using that in place of the
<template #item>
tag and also as a child of it, and nothing I have tried seems to work.It's not really the end of the world, but I am now just curious if this is something that is even possible and if so, I'm more curious as to how to accomplish it. Any time I can minimize duplicate code I will strive for it, no matter how big or small.
Here is an example of what I tried with the reusableTemplate stuff:
And various variations of that like trying to assign #name in the
<ReuseTemplate>
tag and such.Any thoughts or tips on how I might accomplish what I'm trying to do?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions