<分区>
我想检查一个对象是否有新的子对象。我的意思是我有一个包含 x 个嵌套对象的对象,但如果主对象有新对象,我会检查它。是否有任何现有的解决方案来检查这一点?
methods: {
playSound(newOrders, sound) {
if (newOrders.length > 0) {
if (sound) {
var audio = new Audio(sound);
audio.play();
}
}
}
},
beforeUpdate() {
this.playSound(this.newOrders, 'http://soundbible.com/mp3/Elevator Ding-SoundBible.com-685385892.mp3')
},
如果 newOrders
对象有新项目,我的目标是调用函数 playSound
。每次数组更改时,此代码都会调用该函数。
此外,当某些项目被删除时。这部分功能是错误的。有解决办法吗?