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

有方法实现循环打印对象属性和值吗? #34

Closed
sleeplessman opened this issue May 22, 2013 · 1 comment
Closed

有方法实现循环打印对象属性和值吗? #34

sleeplessman opened this issue May 22, 2013 · 1 comment

Comments

@sleeplessman
Copy link

var obj = {"name": "joe", "age": 28, "someProp": "some value"};
{@each obj as objKey}
${objKey} -> ${obj[objKey]}
{@/each}
比如像js里:
for(var key in obj) {
console.log(key + " -> " + obj[key]);
}

@PaulGuo
Copy link
Owner

PaulGuo commented May 24, 2013

var obj = {"name": "joe", "age": 28, "someProp": "some value"};
{@each obj as o, index}
    <% console.log(o); %>
    ${index} -> ${o}
{@/each}

enjoy!

@PaulGuo PaulGuo closed this as completed May 24, 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