方法,计算属性和过滤器之间的区别?

发布于 2025-01-31 04:26:53 字数 192 浏览 0 评论 0原文

我只是回到Vue开发中,对某些主题有些生锈。有人可以解释方法,计算属性和过滤器之间的区别,并描述何时应该使用?

我的理解是,每次对状态进行一些更改时都会调用方法,而仅在对使用特定变量进行更改时,计算的属性和过滤器才会被调用。这是正确的吗?

说滤波器与计算属性基本相同,但是可以采用参数,哪些计算属性不能?

我感谢我对此的任何帮助

I'm just getting back into Vue development and am a bit rusty on certain topics. Could somebody explain the difference between methods, computed properties, and filters, as well as describe when each should be used?

It is my understanding that methods are invoked every time some change is made to the state, whereas computed properties and filters are invoked only when change is made to a specific variable that they are using. Is this correct?

Is it correct to say that filters are essentially the same as computed properties, but can take parameters, which computed properties cannot?

I am grateful for any help with my understanding of this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文