gpt4 book ai didi

vue.js - 如何处理 nuxt.js 中的路由参数更新

转载 作者:搜寻专家 更新时间:2023-10-30 22:47:48 28 4
gpt4 key购买 nike

如果目的地与当前路线相同并且只有参数在变化

going from one profile to another /users/1 -> /users/2.

我如何识别并更新组件?

最佳答案

我不确定 next.js 是否相同,但在适当的路由器中,即使参数更改,相同的组件也会被重用。因此,您需要专门观察 参数更改。

来自 Vue 路由器文档:

One thing to note when using routes with params is that when the user navigates from /user/foo to /user/bar, the same component instance will be reused. Since both routes render the same component, this is more efficient than destroying the old instance and then creating a new one. However, this also means that the lifecycle hooks of the component will not be called.

看这里:https://router.vuejs.org/en/essentials/dynamic-matching.html#reacting-to-params-changes

关于vue.js - 如何处理 nuxt.js 中的路由参数更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49166090/

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