如何在淘汰赛js的函数中使用if? [英] how to use if in a function in knockout js?

查看:25
本文介绍了如何在淘汰赛js的函数中使用if?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的函数中有一个条件.我想根据另一个变量是否为空或不在淘汰赛js中设置变量的值true或false?

i have a condition in my function . i want to set a value of a variable true or false on the basis of another variable whether it is empty of not in knockout js?

 self.editData = function (data) { 
     self.id(data.id());
     self.nscto(data.nscto());
     if (nscto != null && "".equals(nscto)){
         self.view(true)
     }
 }

在这里我写如果条件就像我们在java语言中使用的那样我想在淘汰赛中使用这个场景我该怎么做?

here i write if condition as we use in java language i want to use this scenarion in knockout how can i do it ?

推荐答案

有很多方法可以做你想做的:

There are many ways to do what you want:

if ( null != self.nscto() && "" === self.nscto() )
{
    self.view(true)
}    

if ( null != self.nscto() && self.nscto().length === 0 )
{
    self.view(true)
}

或更简单的

self.view( null != self.nscto() && "" === self.nscto() )

这篇关于如何在淘汰赛js的函数中使用if?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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