Subscribe on changes!

超过最大递归更新以及响应式问题

avatar
Sep 20th 2023

Vue version

3.2.45

Link to minimal reproduction

https://play.vuejs.org/#eNp9U01v2kAQ/Suj7QFQiGnLBTnG/YzU9NBGbaRefHHWY3Cy7Fq7a6BC/u+dWWNwogoO2PPmzaffHMSnuo62DYpYJE7aqvbg0Dc1qFyvlpnwLhNppqtNbayHg8WyhdKaDWSCojJxc/J9Q6XMH2NV0RFG0ewMcYkRcaXRzoM0jfawBMo2fjvp0RX6B9wzPp7AMoVDpoF+7DQKI2VW4xAYbXPV4NXVhPIxwVK/VsO793MC2lMRtza7Y40yVw6Z3nlK/boGc7u05BkYHyCEQgzeNnhMn8y6RdFayPC4qVXukSzOlBTVFqTKnaPlUTmfVxpt2CG7A8XTlOnh0A9MnbRtMgvogPXYeG80fJSqks+UrNSZgDRYyaxzDumD9W+vN6ZAFfMgFMgPaiAZfI6+2Rl1S+9c/DQFmc7/VQhOmhqLXghOOpYCDc9O4okpiYMmLKtV9OSMJgWFbfLYm7pSaH/WvqKFZyLu95yJnFrYfQ8Yr3Ta43KN8vk/+JPbM5aJe4sO7ZYkd/L53NIKO/ft7x+0v4GTVtAoYl9w/kISVsM9drTPjS6o7QEvdHsX9F3p1YO73XvUrh+KG2VmG/jhIL5cGP3c7jyahzjSE23x5ZVcPkRL56Y92jKXCHf31tSOChDaqziGR0PXkusbRlv+U+ihDswl7Cq//opl3ijvxgWWJM6QJOlypePJ9HW+cAHTkI1OiB7DgxytuXnYcfejCXvP10FGAM7aOublG0lD4O6owBD3ghegoQ4DGlnMi2u/xuvCyMHk0ihjY3izWCzOc5+kSu+i/Qd4kajT

Steps to reproduce

1.页面加载,控制台报错“Maximum recursive updates” 2.点击button,运行了一个没调用的函数getText,并控制台再次报错“Maximum recursive updates”

What is expected?

正常运行

What is actually happening?

主要是以下两个问题 1.页面加载后控制台报错“Maximum recursive updates” 2.点击button调用了getText方法,可是我并没有在click事件里调用它 我试图自己弄清楚这个问题,但是经过一天的尝试我失败了,我用computed解决了这个问题,但是还是想知道为什么会出现这种情况

System Info

No response

Any additional comments?

No response

avatar
Sep 20th 2023

You cannot modify the values that the render function depends on during the call of the render function, otherwise it will cause stack overflow.

https://vuejs.org/api/composition-api-lifecycle.html#onupdated

avatar
Sep 20th 2023

The template will be compiled into a render function, so every time the page is updated, the render function will be executed, and the functions called in the render function will also be called.

image

avatar
Sep 20th 2023

Sorry I was influenced by uniapp,didn't notice that the onupdated hook had been called. Thanks for explaining it to me, now I get it.

avatar
Sep 20th 2023

If my answer solves your problem, please close this issue.