vue2 Where should public methods be written?
Create a utils under lib, just import it when you want to use it
Write a util.js and write the methods here. Be careful to expose it as a module. When using it, import it, and then you can use the methods inside
Write a separate JS file, and then expose the method. The VUE page refers to your JS file to call the exposed method
You can also use mixins
Use vueX? Just write it in actions, so that it can be easily called in the component. If you write additional js, it will be troublesome to import every time
Public methods have nothing to do with vue instances
Create a utils under lib, just import it when you want to use it
Write a util.js and write the methods here. Be careful to expose it as a module. When using it, import it, and then you can use the methods inside
Write a separate JS file, and then expose the method. The VUE page refers to your JS file to call the exposed method
You can also use mixins
Use vueX? Just write it in actions, so that it can be easily called in the component. If you write additional js, it will be troublesome to import every time
Public methods have nothing to do with vue instances