Aframe 使用缓存值时.setAttribute出现问题

Aframe 使用缓存值时.setAttribute出现问题,aframe,Aframe,我遇到了一个问题,我正在用类似这样的东西设置组件的数据 document.querySelector("#card1") .setAttribute('card', {assetArray: items.swapper_1, deletedItemNum: nextProps.projects.deletedItemNum, deleteUpdate: true}); 然后在我的更新函数中,我将dele

我遇到了一个问题,我正在用类似这样的东西设置组件的数据

document.querySelector("#card1")
.setAttribute('card', {assetArray: items.swapper_1,
                       deletedItemNum: nextProps.projects.deletedItemNum,
                       deleteUpdate: true});
然后在我的更新函数中,我将deleteUpdate值设置回false。但是,当我回来用类似这样的东西再次更新组件时

document.querySelectorcard1.setAttribute'card',assetArray,items.swapper_1


a-frame正在使用deleteUpdate的缓存值,这是真的,因为我假设我在前面的.setAttribute中使用过它。然后,在我的更新函数中,this.data.deleteUpdate现在为true,尽管我已将其设置回false。不知道如何解决这个问题

在更新函数的末尾,我不得不将this.attrValue.deleteUpdate设置为false。我猜用于.setAttribute的缓存值存储在那里,当您更新属性时,您正在使用的任何未声明的值都将使用我怀疑的缓存值。我可能对它的工作方式有误解,但这就是它看起来的样子。

您是如何设置deleteUpdate的。setAttribute'card','deleteUpdate',false


或者您可以只使用这个。deleteUpdate=false;对于状态变量。

我同时执行了这两项操作。deleteUpdate=false;并且this.data.deleteUpdate=false;,但是,当我再次更新组件时,尝试设置一个不同的属性(如原始帖子中的属性),它会传入以前缓存的数据,并将this.data.deleteUpdate设置回true。我想我可以在运行代码后运行.setAttribute'card','deleteUpdate',false,当我将其设置为true时,但是我试图减少启动更新函数的次数。似乎设置this.data变量也应该更新缓存?不,您不应该直接修改this.data。我们可以将其移出模式并作为组件属性:this.deleteUpdate=false,并始终引用this.deleteUpdate。或者使用.setAttribute正确更新它。您可以优化更新处理程序以区分更改以仅执行您需要的操作;在我的更新函数开始时,所以我无法设置this.deleteUpdate。对不起,这让人困惑。我想答案是运行另一个.setAttribute'card','deleteUpdate',false来更新this.data.deleteUpdate,就像你刚才说的那样。