Vue.js.使用事件总线或存储哪个更好?

编程入门 行业动态 更新时间:2024-10-11 21:28:15
本文介绍了Vue.js.使用事件总线或存储哪个更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我在页面上有 2 个组件.其中之一是过滤器,另一个是结果列表.

I have 2 components on the page. One of them is filters and other is list of results.

制作了两个组件的原因:1. 它们太大,无法在单个组件中使用2. 分开制作.我可以使用没有过滤器的列表组件.

Two components have been made in reasons: 1. They are too large to use in single component 2. Made them separately. I can use list component without filters.

现在组件通过总线事件进行通信.我的问题是:我是继续使用总线事件还是删除它并通过 vuex 存储制作?".

Now components are communicated via Bus event. And my question is: "Do I continue to use bus event or delete it and make via vuex storage?".

附言我想听听真实的 еips 和解释

P.S. I would like to hear real еips with explanations

P.S.S.请不要写你是白痴"之类的话.

P.S.S. Please don't write something like "you are idiot" and etc.

推荐答案

我想这是分析您的需求的问题.我通常是这样想的:

I guess it's a matter of analyzing your needs. I usually think like this:

如果是只在那里发生的简单事件,请使用总线.如果这些过滤器不是在父级中使用的,则存储它们.Vuex 已经到位,所有逻辑都已存储,为了一致性而存储.

If it's a simple event that only happens there, use the bus. If those filters are used other than in the parent, store them. Vuex is already in place and every logic is stored, store it for sake of consistency.

这篇关于Vue.js.使用事件总线或存储哪个更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-27 01:16:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1145628.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:总线   事件   Vue   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!