javascript - 数组上的 Vue.js 过滤器 id
问题描述
如何在 vue.js 上进行这样的过滤?
$followid = [1,2,3,4,4,5];
foreach ($array as $element)
if (in_array($element->id, $followid))
endif
endforeach
解决方案
您不应该为此用例使用过滤器。我不确定您是否可以在过滤器中访问“this”。我鼓励您使用返回要显示的数组的计算属性。
computed: {
actifOnline: function() {
let self = this;
return this.online.filter((o) => {
return self.editlistAssesments.indexOf(o) > -1
}
}
}
推荐阅读
- javascript - Mock imported function with jest in an await context
- javascript - Asynchronous code in nested forEach loop- react native
- python - AttributeError when using ColumnTransformer into a pipeline
- html - Display Flex in Safari align
- r - 从原始向量创建数据框
- javascript - 在没有模块加载器的 ES6 模块系统(在浏览器中)中使用 rxjs
- python - Django problem - cannot get the value from the front - query value is none
- sharepoint-2013 - 如何使用代码将 SharePoint 列表导出到 Excel
- angular - 从组件中的 observable 获取属性
- reactjs - 异步操作失败后推送到历史记录