Vue中v-for如何在当前行取到数据

图片描述

图片描述

如上图,如何在v-for当前行的语句取到循环到的数据?以下是现在报的错误信息:

[Vue warn]: Error compiling template:

<ul class="list-group pmd-card-list pmd-list todo-lists" id="console-service-all-list">
                    <li v-for="d in info" class="list-group-item timeline {{ d.t }}">
                        <span>{{ d.msg }}</span>
                        <h5 class="typo-fill-secondary">{{ d.time }}</h5>
                    </li>
                </ul>

- class="list-group-item timeline {{ d.t }}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div class="{{ val }}">, use <div :class="val">.


(found in <Root>)
阅读 4.7k
1 个回答

不能在属性里用插值语法了

你可以这样写:<li v-for="d in info" class="list-group-item timeline" :class="d.t">

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题