如何检查没有长度的选项?有些options
估计options
,另一些则没有。
当我检查options.length == 0
const { group, data, year } = args;
return (
data
.find(element => {
return element.id == year;
})
.options.find(element => {
return element.id == group;
}).options.length == 0
数据:
years: [
{
label: "Year 3",
id: 1,
options: [
{
label: "Firm 01",
id: "xxx@xx.co.uk"
},
{
label: "Firm 02",
id:
"xxx.co.xxx@group.calendar.google.com"
}, ....
答案 0 :(得分:0)
我认为最好的方法是检查是否定义了变量,可以通过以下方式实现:
class SplashPresenter extends BasePresenter<SplashView> {
private Scheduler mMainThread;
private Scheduler mNewThread;
private UserAuthService userAuthService;
@Inject
SplashPresenter(SplashView view, UserAuthService userAuthService, @Named(ValueConstants.NEW_THREAD) Scheduler newThread, @Named(ValueConstants.MAIN_THREAD) Scheduler mainThread) {
super(view);
this.userAuthService = userAuthService;
mNewThread = newThread;
mMainThread = mainThread;
}
让我知道这是否对您有用。