在vuejs中将vfor属性添加到dynamic:style中

2024-03-28 15:46:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这样的结构:

<div v-for="item in principal" class="cardgrande cardeffects imagehover">
  <div v-bind:style='{ background: "linear-gradient(0deg,rgba(0,0,0,.6),rgba(0,0,0,.2) 40%,rgba(0,0,0,.2) 80%,rgba(0,0,0,.4)), url(" + item.midia + ")", }' class="flexcolumn card">
    <div class="texto">{{item.titulo}}</div>
  </div>
</div>

这个项目.midia不符合我的动态风格。我需要得到这个,因为它是我的图像的url(从v-for获得)。在


Tags: indivprincipalurlforbindstyleitem
2条回答

尝试使用返回样式的方法

  <div v-for="item in principal" class="cardgrande cardeffects imagehover">
    <div :style="itemStyle(item)" class="flexcolumn card">
      <div class="texto">{{item.titulo}}</div>
    </div>
  </div>

添加以下方法

^{pr2}$

你不需要这里的大括号。只需添加表单的动态属性:

<tag :attribute="'selector:' + yourVariable" />

也可以使用^{}代替background来设置多个背景图像。你的情况是:

^{pr2}$

请参阅the docs以获取参考。在

相关问题 更多 >