vue.js - Nuxt Js 在每次迭代时设置值 v-for
问题描述
我有这段代码,我想找出一种getPickedTeam
每次迭代都调用一次的方法,我知道我不能每次都将它设置为数据属性,因为它会创建一个无限的重新渲染循环。
我想设置 PickedTeam 的原因是因为我需要在同一次迭代中至少调用它 5 次,所以如果我为 40 条记录找到团队 5 次,它会非常慢。
<span :key="match.id" v-if="matchViewable(match)" class="center-item">
{{ getPickedTeam(record.resultMatches, match).pickedTeam }}
<span v-if="match.mondayNight">
<b>{{ getPickedTeam(record.resultMatches, match).pickedTeam }}</b>
</span>
//i'd like to call getPickedTeam here about 3 more times but it will become slow
</span>
在我的方法中,我有这个
getPickedTeam(picks, match) {
const team = picks.filter(function(pick) {
return pick.match.id == match.id;
})[0];
if (team) {
return team;
}
}
也许有一种方法可以使用 vuex 商店设置 getPickedTeam 但我是菜鸟,我不知道如何:(
解决方案
推荐阅读
- scala - MLlib MatrixFactorizationModel RecommendationProducts(user, num) 还返回训练数据产品项
- javascript - Double rendering in React with asynchronous call in componentDidMount causing error
- html - Angular generated css breaks child combinator
- git - Git添加预提交钩子而不是暂存文件以进行提交
- asp.net-web-api2 - Swagger ui 无法在服务器中加载 json 规范文件
- javascript - 从另一个组件更改组件的属性并在 html 中以角度 2 呈现它
- python - 熊猫中的数据操作 - python
- android - android在usb附件模式下无法接收512bytes的数据
- c# - 为什么 AsyncLocal 不从 OWIN 中间件流向 WebForms 页面?
- javascript - React - 通过关键字搜索反应中的项目列表