You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在F7+Vue中通过v-for循环更新accordion-item标题

Setting Accordion Item Titles with v-for in Framework7 Vue

Hey there, your approach is on the right track! The main adjustment you need to make is how you bind the dynamic title value to the accordion item component. In Vue, when passing dynamic values to component props, we use v-bind (or its shorthand :) instead of mustache syntax {{}} directly in the attribute.

Here's the refined, working version of your code:

<f7-list-item 
  v-for="(value, index) in myList" 
  :key="index" 
  accordion-item 
  :title="value.Title"
>
  <f7-accordion-content>
    <f7-block>
      <p>{{value.foo}}</p>
      <p>{{value.boo}}</p>
    </f7-block>
  </f7-accordion-content>
</f7-list-item>

A couple of key improvements to note:

  • Added :key="index" to the v-for loop. Vue requires a unique key for list items to efficiently track changes and re-render components correctly. If your myList objects have a unique identifier (like value.id), use that instead of index for optimal performance.
  • Replaced title="{{value.Title}}" with :title="value.Title". This properly binds the Title property from each array object to the accordion item's title prop, which is the standard Vue way to pass dynamic values to component attributes.

With this code, every object in your myList array will generate an accordion item with its Title as the header, and the inner content will display the corresponding foo and boo properties when expanded.

内容的提问来源于stack exchange,提问作者jremi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:43:09