Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

比如我的json里面没有内容,是一个空的数组,我怎么获得这个数组的长度 #28

Closed
tianyirenjian opened this issue Feb 17, 2013 · 2 comments

Comments

@tianyirenjian
Copy link

json代码如下:
var data={ "httop10" : [{"pid":"1", "ftpuser":"tianyi", "domainname":"webabc.com", "starttime":"2013-1-1", "endtime":"2015-1-1", "state":"1"}]};
这个是正常情况下,我可以获得一条结果,但是有的查询条件得到的结果是空的。
var data={ "httop10" : []};
我想在判断如果是空的话,我要显示一句话 “没有查询到结果”,但是没有找到判断这个长度的方法。
{@each httop10 as ht,index}
{@if httop10.length==0} //关键是这句,是不是如果是空的,就不会走each了
没有查询到结果
{@else}
{#这事正常情况下的}
{@/if}
{/each}
起初是认为不走each那里了,我把那一句单独拿到了外面
{@if httop10.length==0}

没有查询到结果 {/if} 这样会输出一个undefined。。。 麻烦告诉一下怎么解决,谢谢了
@tianyirenjian
Copy link
Author

可以得到了,我写错了,少些了一个@,新手,见谅

@PaulGuo
Copy link
Owner

PaulGuo commented Feb 17, 2013

:)

@PaulGuo PaulGuo closed this as completed Feb 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants