如何在淘汰赛中的一个函数中使用? [英] how to use if in a function in knockout js?
本文介绍了如何在淘汰赛中的一个函数中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的功能有条件。我想在另一个变量的基础上设置一个变量true或false的值是否为空,而不是在淘汰js中?
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() )
这篇关于如何在淘汰赛中的一个函数中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文