1

JSON オブジェクトが与えられた場合:

errors =
{ 
  hashed_password: { 
     message: 'Validator "Password cannot be blank" failed for path hashed_password',
     name: 'ValidatorError',
     path: 'hashed_password',
     type: 'Password cannot be blank' },
  username: { 
     message: 'Validator "Username cannot be blank" failed for path username',
     name: 'ValidatorError',
     path: 'username',
     type: 'Username cannot be blank' },
  email: {
     message: 'Validator "Email cannot be blank" failed for path email',
     name: 'ValidatorError',
     path: 'email',
     type: 'Email cannot be blank' },
  name: { 
     message: 'Validator "Name cannot be blank" failed for path name',
     name: 'ValidatorError',
     path: 'name',
     type: 'Name cannot be blank' } 
}

各「現在のコンテキスト」オブジェクトのプロパティを反復処理するにはどうすればよいですか?

私はあなたがこのようなことをすると思います:

{#errors}
    {#.}
         {type}
    {/.}
{/errors}
4

3 に答える 3

4

本当に意味のあるデータをオブジェクト キーに入れる必要がある場合は、次のようにコンテキスト ヘルパーを作成することを検討してください。

于 2013-03-08T11:59:34.450 に答える