gpt4 book ai didi

Javascript 数组观察

转载 作者:行者123 更新时间:2023-12-02 13:54:37 24 4
gpt4 key购买 nike

observe(arr,callback) 与 riot.js 结合使用

但是当我尝试观察我的数组时,我得到Array.observe is not a function

Array.observe(this.nodes, function (changes) 
{
//do some stuff
tag.update();
});

错误

Uncaught TypeError: Array.observe is not a function(…)(anonymous function)
@components/breadcrumb-navigation.tag.js:3(anonymous function)
@ riot+compiler.js:1604(anonymous function)
@ riot+compiler.js:1719each
@ riot+compiler.js:1921toggle
@ riot+compiler.js:1719(anonymous function)
@ riot+compiler.js:1610mountTo
@ riot+compiler.js:2417pushTags
@ riot+compiler.js:2557each
@ riot+compiler.js:1921pushTags
@ riot+compiler.js:2561riot.mount
@ riot+compiler.js:2612(anonymous function)
@ riot+compiler.js:3497done
@ riot+compiler.js:3414compileTag
@ riot+compiler.js:3421GET.req.onreadystatechange
@ riot+compiler.js:3381

最佳答案

Array.observe方法已过时并已被删除。
使用Proxy相反,建议这样做。

关于Javascript 数组观察,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40789195/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com