The method of introducing out-of-file functions in vue

I have some doubts. In the vue project, a vue file wants to use a method defined elsewhere, and there seem to be many ways available:
1.js file in the form of vue.use () global introduction of
2.js file in the form of vue.prototype global introduction of
3.js file window global registration
4. When defining methods in js files, introduce
5. eventBus- -this seems to use the above forms
6. vuex
what I have said may be incomplete, welcome to add or correct. My question is: what are the similarities and differences between these methods or use environment , and how should I make a choice

?
Nov.24,2021

Thank you for inviting ~ actually don't understand what you want to ask.

use functions, or methods, outside the file.
usually encapsulates a utils.js file, which defines some methods, such as formatting time formatTime .
use import .

all of the things you list have different scenarios and solve different problems. The plug-in Vue.use () is your own plug-in or someone else's plug-in.
self-encapsulated utils.js is a separate method.
the so-called similarities and differences.
is written differently and solved differently.
such as mixins is also a type, often including data,computed,methods and other . It is different from utils.js .
I don't know if this answer is an answer.


1. As mentioned upstairs, Vue.use () is a plug-in for yourself or someone else.
2.vue.prototype, of course, mounts some globally commonly used things on the vue prototype, such as some globally commonly used filters (time format, amount format), and axios, and so on.
3. Things mounted on the window, such as the url address of the http request, will be configured and replaced according to the development environment and the online environment.
4. This general definition is that ok is introduced into main.js.

  1. eventBus this is generally encountered in component cross-level communication, of course, the common communication methods are props and $emit.
The choice of

6.vuex is a big one on the Internet, and you can search it casually.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35d0e-2bfb9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35d0e-2bfb9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?