Component State and Events

Learn how to manage the component state and handle events in Vue using TypeScript.

Component state

The properties that a component exposes to a parent component are read-only. This means that only the parent component can change these properties and that the flow of data is one-way, from parent to child. If our component needs to maintain its own state and update an internal property, such as the value from an input control, we will need a place to store this state. Vue components use a function named data that returns a structure for storing the internal state.

Let’s update our HelloWorld component and introduce an internal property named myText as follows:

Get hands-on with 1200+ tech skills courses.