功能是有一個總數組 一個分數組 分數組包含在總數組中,把總數組中和分數組不同的數組元素篩選出來
this.AllLIstcommend : 總數組
this.userChannel : 分數組
computed: { //計算屬性 recommendChannele () { const channels = [] //新建一個新數組 this.AllLIstcommend.filter((item, index) => { //從總數組中篩選遍歷 item就是每個數組元素 const ret = this.userChannel.find(userChannel => { //從分數組中找每個元素 當總數組元素等於分數組元素 return userChannel.id === item.id //說明一樣 不符合要求 }) if (!ret) { channels.push(item) // 不一樣 符合要求 (總數組中和分數組不同的數組元素篩)
} }) // 把計算結果返回 return channels } } //計算屬性要返回結果