Vue lets you connect your data (state) to your HTML easily. Instead of manually updating the page, you simply write your HTML to "reflect" your data. When your data changes, Vue automatically updates the HTML.
-
Reactive State:
- Use
reactive()
for objects (like counters, lists, etc.). - Use
ref()
for simple values (like strings or numbers). When you change these values, Vue updates your page.
- Use
Using in Templates:
Write your HTML with mustache syntax ({{ }}
) to show your data. For example:
<h1>{{ message }}</h1>
<p>Count is: {{ counter.count }}</p>
No extra code is needed—Vue does the updating for you!
In short, declarative rendering means you declare what your UI should look like based on your data, and Vue keeps it all in sync automatically.
Top comments (0)