2017-09-15 4 views
0
export default [ 
{ 
    user:{ 
     id: '1', 
     person: 'Theodore Roosevelt', 
     text: 'Believe you can and you\'re halfway there', 
     icon:'man' 
    } 
}, 
{ 
    user:{ 
     id: '2', 
     person: 'Normale', 
     text: 'Change your thoughts and you change your world.', 
     icon:'woman' 
    } 

}, { 
    user:{ 
     id: '3', 
     person: 'Thlt', 
     text: 'Believe you can and you\'re halfway there', 
     icon:'man' 
    } 
}] 

上記のコードはイオンツールのデータフォルダの下にあるtsファイルです。
idに基づいてこの配列からエントリーを削除するには、各エントリーの前にある削除ボタンをクリックしてください。 私はイオン性が新しいです。私はそれが動作しませんでした.slice角度2とイオンのjsonからオブジェクトを削除する方法

+0

はあなたがしようとしているかを示す試してみました – Sajeetharan

答えて

0

const arr = [{ 
 
    user:{ 
 
     id: '1', 
 
     person: 'Theodore Roosevelt', 
 
     text: 'Believe you can and you\'re halfway there', 
 
     icon:'man' 
 
    } 
 
}, 
 
{ 
 
    user:{ 
 
     id: '2', 
 
     person: 'Normale', 
 
     text: 'Change your thoughts and you change your world.', 
 
     icon:'woman' 
 
    } 
 

 
}, { 
 
    user:{ 
 
     id: '3', 
 
     person: 'Thlt', 
 
     text: 'Believe you can and you\'re halfway there', 
 
     icon:'man' 
 
    } 
 
}] 
 

 
const id = '2'; // 2 will be removed 
 
const result = arr.filter(item => (item.user || {}).id !== id) 
 
console.log(result)

関連する問題