how to use if in a function in knockout js?

后端 未结 3 1402
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 05:42

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?



        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 06:13

    There are many ways to do what you want:

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

    or

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

    or simpler

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

提交回复
热议问题