我想替换这类代码:
template(v-slot:item-title.1)
.tab
ThemeIcon(themeId="welcome")
div Welcome
template(v-slot:item-title.2)
.tab
ThemeIcon(themeId="themes")
div Themes
template(v-slot:item-title.3)
.tab
ThemeIcon(themeId="timeline")
div Timeline使用运行在数据对象上的循环:
template(v-for="(tab, index) of tabs" v-slot:item-title.index)
.tab
ThemeIcon(:themeId=tab.themeId)
div tab.content但我不知道如何表示动态v-槽属性("v-slot:item-title.index")。这能办到吗?
(这里的语法是Pug,以防混淆)。
发布于 2022-11-01 03:06:49
这应该是可行的:
template(v-for="(tab, key) of tabs" :key="key" v-slot:[`item-title.${key + 1}`])
.tab
ThemeIcon(:themeId="tab.themeId")
div {{tab.content}}https://stackoverflow.com/questions/74270779
复制相似问题