[Vuejs]-VueJS where to declare props in shared components

4👍

Only the first is valid. The second may or may not work, but props aren’t data. Don’t even try to define them as such.

Consider adding the Vue eslint plugin to your build and use the recommended rules to catch anything that seems out of the ordinary. It will teach you how to write uniform Vue code by outputting errors whenever you do something that is not usually done.

1👍

From other stack question:
Properties are meant to be propagated and managed from parent components, while data is the component internal state (which the component is responsible for).
This concept is taken from React as far as i know, and it works pretty well. https://github.com/uberVU/react-guide/blob/master/props-vs-state.md

Now depends if your variables depends on the parent or they are independent based on other data.

I prefer use props if doesn’t make the parent component to add or change the logic, but every component is different.

Leave a comment