What access modifiers should I use for the class-component in Vue? What access modifiers should I use for the class-component in Vue? typescript typescript

What access modifiers should I use for the class-component in Vue?


Public: You can access the property or method from any class.

Protected: You can access the property or method within the same class or any child classes

Private: You can access the property or method within the same class, but not outside of that class.

See here for reference.

Using public is usually fine as long as you don't care whether another component modifies that value or calls that function. I would just use public by default and then replace it with private or protected when necessary.

Turning off the linter works as well, but if you run into issues between components and you haven't defined access modifiers for properties or methods that are used between the components, it can be a nuisance to debug.