VueJS 中 Angular Service 的等价物是什么? [英] What's the equivalent of Angular Service in VueJS?
本文介绍了VueJS 中 Angular Service 的等价物是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将所有与服务器通信并获取数据的函数放入 VueJS 中的单个可重用文件中.
I want to put all my functions that talk to the server and fetch data into a single reusable file in VueJS.
插件似乎不是最好的选择.模板较少的组件......?
Plugins don't seem to be the best alternative. Template less components..?
推荐答案
一共有4种方式:
- 无状态服务:那么你应该使用 mixins
- 有状态的服务:使用 Vuex
- 导出服务并从 vue 代码导入
- 任何 javascript 全局对象
这篇关于VueJS 中 Angular Service 的等价物是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文