首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >动态v槽名

动态v槽名
EN

Stack Overflow用户
提问于 2022-11-01 02:03:17
回答 1查看 17关注 0票数 0

我想替换这类代码:

代码语言:javascript
复制
    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

使用运行在数据对象上的循环:

代码语言:javascript
复制
   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,以防混淆)。

EN

回答 1

Stack Overflow用户

发布于 2022-11-01 03:06:49

这应该是可行的:

代码语言:javascript
复制
template(v-for="(tab, key) of tabs" :key="key" v-slot:[`item-title.${key + 1}`])
  .tab
    ThemeIcon(:themeId="tab.themeId")
    div {{tab.content}}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74270779

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档