骨干收集找到我想要结果只有一个 [英] Backbone collection find I want only one result

查看:208
本文介绍了骨干收集找到我想要结果只有一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与查找骨干工作,我有20-30个结果,我需要第一个结果,我没有ID为过滤器ID。

 模型= coleccion.find(
    功能(E){
        返回(
           。e.get('车')===类和data_category功放;&安培;
           e.get('full_empty')=== 0安培;&安培;
           e.get('idprovider')=== data_provider
        );
    }
);


解决方案

您可以使用collection.at(0)如果你想获得的第一款车型。
或collection.shift()如果你想获得的第一个模型,然后从收集这种模式。
更多在 Backbonejs收集

I'm working with find Backbone and I have 20-30 results, I need the first result and I don't have the id for filter for id.

model = coleccion.find(
    function(e){
        return (
           e.get('car').category === data_category &&
           e.get('full_empty') === 0 &&
           e.get('idprovider') === data_provider
        );
    }
);

解决方案

You can use collection.at(0) if you want to get the first model. Or collection.shift() if you want to get the first model, then remove this model from the collection. Read more at Backbonejs Collection

这篇关于骨干收集找到我想要结果只有一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆